How to get to value in a nested array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smalugu
Forum Newbie
Posts: 1
Joined: Sun Aug 10, 2008 1:12 am

How to get to value in a nested array

Post by smalugu »

Hi All,

I have an array of the following structure

Array ( [string1] => Array ( [0] => attrib Object ( [id] => 22:42 [identifier] => string1 [value] => diamond ) ) )

which I got my print_r.

Now my problem is how to get to the value which is corresponding to the [value] i.e here 'diamond'. :banghead:

I have tried several things including
$arr[0][0][value]
$arr->string1->value

or even a plain $arr[0] but i am getting syntax error.

Thanks for helping me
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: How to get to value in a nested array

Post by Oren »

Try:

Code: Select all

$arr['string1'][0]->value
Post Reply