如何通過此對象循環並閱讀conversion_id
。我嘗試了以下foreach,但我似乎做錯了。Foreach通過對象循環
<?php
foreach($result->response->data as $key=>$value) {
echo $value->Stat->conversion_id.' ';
}
?>
stdClass Object
(
[response] => stdClass Object
(
[status] => 1
[data] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[Stat] => stdClass Object
(
[conversion_id] => 351140
)
)
[1] => stdClass Object
(
[Stat] => stdClass Object
(
[conversion_id] => 355704
)
}
)
)
)
)
的foreach只適用於數組。你必須通過該對象中的數組變量循環訪問 – clem