I have some data which was json decoded and looks like this:
stdClass Object
(
[6] => stdClass Object
(
[13] => stdClass Object
(
[buildingId] => 1
)
)
[8] => stdClass Object
(
[20] => stdClass Object
(
[Id] => 1
)
)
Thing is i don’t know how to loop to get the information to use it in my script.
I need to get for example:
$key, $innerkey, $Id = 1
Object [8][20].Id = 1
The two numbers are X;Y co ordinates so its important i get those values aswell as the id.
I managed to get the first key:
$obj = JSON_decode($_GET['data']);
foreach($obj as $key) {
echo $key;
}
How do i get the innerkey assigned to a variable ?
Change
json_decode($_GET['data']);tojson_decode($_GET['data'], true);If the second parameter is
truethen it return the array else it is object.Ref: http://php.net/manual/en/function.json-decode.php