I have json like this from a remote url
[{"Name":"Abcd","Alias":["Bcde","Cdef","Fghi","Jklm","Load more"]}]
When I try to print the element aliases as follows Im getting errors like "trying to get non-object property ..."
<?php
$json='[{"Name":"Abcd","Alias":["Bcde","Cdef","Fghi","Jklm","Load More"]}]';
$obj=json_decode($json);
foreach($obj->Alias as $val)
echo $val.'<br/>';
?>
The decoded json array is as follows
Array
(
[0] => stdClass Object
(
[Name] => Abcd
[Alias] => Array
(
[0] => Bcde
[1] => Cdef
[2] => Fghi
[3] => Jklm
[4] => Load More
)
)
)
I would also like to exclude the last "Alias" element (Download more) from the result
Plz ... help in advance
source
share