Brad m
Brad m

Reputation: 97

getting value from stdclass object/array

ive been trying for a while now trying to get a value from this std object

stdClass::__set_state(array(
   'regions' => 
  array (
    0 => 
    stdClass::__set_state(array(
       'id' => 1,
       'name' => 'Canada',
       'image_url' => 'https://s3-us-west-2.amazonaws.com/staticimageskiind/flags/[email protected]',
    )),
    1 => 
    stdClass::__set_state(array(
       'id' => 2,
       'name' => 'USA',
       'image_url' => 'https://s3-us-west-2.amazonaws.com/staticimageskiind/flags/[email protected]',
    )),
    2 => 
    stdClass::__set_state(array(
       'id' => 3,
       'name' => 'Global',
       'image_url' => 'https://s3-us-west-2.amazonaws.com/staticimageskiind/flags/[email protected]',
    )),
    3 => 
    stdClass::__set_state(array(
       'id' => 4,
       'name' => 'Australia',
       'image_url' => 'https://s3-us-west-2.amazonaws.com/staticimageskiind/flags/[email protected]',
    )),
  ),
   'info' => 
  stdClass::__set_state(array(
     'code' => 'INFO_MARKETPLACE_RETRIEVED_REGIONS',
     'name' => 'Marketplace Regions Retrieved',
     'message' => 'A list of marketplace regions has been retrieved.',
  )),
));

but i can't seem to get a value from this object, help would be appreciated, ive searched online but couldnt find out a solution

Upvotes: 1

Views: 1861

Answers (2)

Yeray
Yeray

Reputation: 130

Did you try:

echo $object->regions[0]->name;

For example?

Upvotes: 3

Brad m
Brad m

Reputation: 97

i have managed to get the correct output i wanted by

$abc = $result->regions;
echo $abc[1]->name;

hope this helps anyone in need

Upvotes: 0

Related Questions