1

$arrayOfEmails=$_POST["arrayOfEmails"];

1st question: $arrayOfEmails is now just an array in JSON notation. How would I convert this to a PHP array?

$arrayOfDictionaries=...

//after querying the db, this gets assigned a JSON string, which was originally an objective c array of dictionaries. So after it's converted to a PHP array,

$dictionaryToBeAdded=$_POST["dictionary"];

The above is now only a non-decoded JSON string, originally an Objective C dictionary, then converted.

2nd question: I need to convert this dictionary to PHP and then add it to the arrayOfDictionaries above. How could I do this?

(I'm not very familiar with PHP syntax)

1 Answer 1

2

For #1, Use json_encode() and json_decode().

For #2, just do $arrayOfDictionaries[] = [whatever your new row is]. Is that what you're looking for?

Sign up to request clarification or add additional context in comments.

2 Comments

So for #2, $arrayOfDictionaries[]=$dictionaryToBeAdded would insert dictionaryToBeAdded to my arrayOfDictionaries?
Yes. In that case, the index will be 0, 1, 2, etc. If you do $arrayOfDictionaries['my_key_name'] you can create an associative array instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.