I am getting a value such as this returned:
{"id":"2","digit":"2","msg":""}
I am trying to access it by doing:
$x = 0;
foreach ($array as $row) {
$res[$x]["col1"] = $row["col1"];
$x ;
}
then that works without a hitch...what am I missing??
CodePudding user response:
That does not look like a PHP array that you are getting back. You can try casting it to an array
foreach ((array) $array…)
Or you could try json_decode
json_decode($array, true)
Edit: Added true to json_decode from comment. Thanks!