I'm trying to decode json string using following code
$jsonString = "[\"a@gmail.com\",\"b@gmail.com\",\"c@gmail.com\"]";
$arrayOfEmails=json_decode($jsonString);
This code works fine. But When I $_POST
this string via form & then try to decode on other page, It shows NULL.
I checked for string value after post on other page & it returns as "[\"a@gmail.com\",\"b@gmail.com\",\"c@gmail.com\"]";
But when I try decode this $_POST
string as follow, It shows NULL.
if ($_POST) {
$string = $_POST['my_string'];
$arrayOfEmails=json_decode($string);
}
What I'm doing wrong ?