I have the following JSON string, which was an Objective C array then encoded to JSON:
$jsonString=[\"a@gmail.com\",\"b@gmail.com\",\"c@gmail.com\"]
I want to convert this to a regular PHP array. I’ve tried many things but none of them seem to work:
$arrayOfEmails=json_decode($jsonString); //doesn't work
$arrayOfEmails=(array)json_decode($jsonString); //doesn't work
Any ideas?
Edit:
I’m still not getting it to work.
$decodeEmails=$_POST["arrayOfEmails"];
sendResponse(200, $decodeEmails);
//the above returns exactly whats after this colon:[\"a@gmail.com\",\"b@gmail.com\",\"c@gmail.com\]
I need to do this: $arrayOfEmails=json_decode($decodeEmails);
But I think I need quotes around $decodedEmails for this to work. How can I add quotes around $decodeEmails string?
You should quote your string, it works fine, see here.
Or