Hi I want to get the name in this objects how can I get these names for each stdClass.
stdClass Object
(
[page] => 0
[items] => 10
[programItems] => stdClass Object
(
[programItem] => Array
(
[0] => stdClass Object
(
[@id] => 8955
[name] => name
)
[1] => stdClass Object
(
[@id] => 8955
[name] => name1
I get this data with
$data = json_decode(file_get_contents("http:/example.com"));
Considering $arr
has the std object data,
$arr->page;
$arr->items;
foreach($arr->programItems as $a){
foreach($a as $b) {
echo $b->name;
...
}
}
This should do the trick :
$programItem = $data->programItems;
foreach($programItem as $item){
echo $item->name;
}
Here your will get the json data in $stdobj
$stdobj=json_decode(file_get_contents("http:/example.com"));
echo "Page = ".$stdobj->page."<br>";
echo "item = ".$stdobj->item."<br>";
foreach ($stdobj->programItems as $datas) {
foreach ($datas as $data) {
foreach ($data as $key => $value) {
echo 'key = ' . $key . ', value :' . $value . '<br/>';
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.