I want to get the last element in the JSON decoded array, Error I am getting
Warning: end() expects parameter 1 to be array
$data
output
stdClass Object (
[contact001] => stdClass Object ( [age] => 33 [name] => Robert [tel] => 87778787878787878 )
[contact002] => stdClass Object ( [age] => 33 [name] => Calvin [tel] => 87778787878787878 )
)
PHP code:
$namejson = $firebase->get(DEFAULT_PATH . '/name/');
$data=json_decode($namejson);
foreach ($data as $key => $value) {
echo end($key);
}
Warning: end() expects parameter 1 to be array