Have JSON as $json
I convert it to an array using:
$myarray = json_decode($json, true);
print_r($myarray) gives this:
Array (
[0] => Array
( [ProjectId] => 2765297 [ProjectName] => Acme Example)
[1] => Array
( [ProjectId] => 4526847 [ProjectName] => Smiths Example)
)
When I try to use foreach like this:
foreach ($results as $key => $result) {
echo $result[ProjectName] . ' Project ID:' . $result[ProjectID];
}
I get the ProjectName but not the ProjectID.
When I look as the original JSON ($json), the ProjectID appears to be unquoted like an integer.
[
{
"ProjectId":2765297,
"ProjectName":"Acme Example"
},
{
"ProjectId":4526847,
"ProjectName":"Smiths Example"
}
]
When I try to convert to a string or run checks to see if it is an integer, it is ether blank or null.