Reputation: 73
How do i loop thru this object and read the conversion_id
. I tried the following foreach, but i seems like I'm doing it wrong.
<?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
)
}
)
)
)
)
Upvotes: 0
Views: 63
Reputation: 670
You missed "data" and "Stat" objects:
<?php
foreach( $result->response->data->data as $key=>$value ) {
echo $value->Stat->conversion_id;
}
?>
Upvotes: 2