Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.