Jump to content

Extacting elements from Array?


natasha_thomas

Recommended Posts

Folks,

 

How can i extract all the elements from the below Array?

 

Arrayname is: $yahooterms

 

Array ( [ResultSet] => Array ( [Result] => Array ( [0] => calla lily [1] => hair pins [2] => crystal crown [3] => red lingerie [4] => red crystal [5] => red wedding [6] => silver link [7] => necessary objects [8] => hair clip [9] => crystal necklace [10] => bridal wedding [11] => link bracelet [12] => appliques [13] => corsage [14] => organza [15] => swarovski crystal [16] => butterflies [17] => gems [18] => balloons [19] => sewing ) ) )

 

 

i am using

 

foreach($yahooterms as $replace)

{

    echo $replace->ResultSet->Result;

 

}

 

 

 

But its not working....  :(

Link to comment
https://forums.phpfreaks.com/topic/233007-extacting-elements-from-array/
Share on other sites

The arrow syntax $object->var->var is for OBJECT, the bracket syntax $array['key']['key'] is for ARRAYS.  You cannot use the object syntax on an array, or the array syntax on an object (unless you implement the proper interfaces for that object). 

 

You can, however, have an array of arrays of objects, or an object containing an array.  The key is to use the proper operator for the job. 

 

Also, you need to start developing with error_reporting turned all the way to E_ALL, so that you'd get the proper error about using an object operator on a non-object.

 

-Dan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.