array(85) {
[0]=>
object(stdClass)#9 (18) {
["offer_id"]=>
string(8) "12345678"
["offer_name"]=>
string(39) "Offer Name"
["offer_desc"]=>
string(209) "Offer Description"
["call_to_action"]=>
string(57) "Offer CTA"
["offer_url"]=>
string(80) "Offer URL"
["offer_url_easy"]=>
string(106) "Offer URL Easy"
}
[1]=>
object(stdClass)#11 (17) {
["offer_id"]=>
string(8) "87654321"
["offer_name"]=>
string(24) "Offer Name 2"
["offer_desc"]=>
string(107) "Offer Description 2"
["call_to_action"]=>
string(107) "Offer CTA 2"
["offer_url"]=>
string(80) "Offer URL 2"
["offer_url_easy"]=>
string(106) "Offer URL Easy 2"
}
I am pulling a response from an API which contains an array with objects inside. I am trying to go through each object and get the value of each key.
For example I want to output: Offer ID: 12345678, Offer ID 2: 87654321
Currently my code is only outputting one ID (the first objects ID).
$arr = $offer_data->response->offers; //Outputs above array
foreach ($arr as $value)
{
return $value->offer_id;
}
Output: 12345678
Note: This is inside a function that I just echo.
Been trying different ways for hours, finally coming here. Thanks for any help you provide.
$value["offer_id"]