Page 1 of 1
echoing something from multidimensional array
Posted: Thu Jul 21, 2011 7:07 am
by naggi
I have an array that looks like this if I use print_r:
Code: Select all
print_r($row);
Array ( [0] => stdClass Object ( [id] => 4 ))
How I can echo that id out?
echo $row->id doesnt seem to work.
Re: echoing something from multidimensional array
Posted: Thu Jul 21, 2011 8:09 am
by Corvin
Re: echoing something from multidimensional array
Posted: Thu Jul 21, 2011 9:42 am
by AbraCadaver
The array item is an object and id is a property of that object:
Re: echoing something from multidimensional array
Posted: Fri Jul 22, 2011 2:30 am
by naggi
Oh cool that works! Nice thanks.
How about if there is second array inside. How to echo that one?
Code: Select all
Array ( [0] => Array ( [0] => stdClass Object ( [id] => 3 )))
Re: echoing something from multidimensional array
Posted: Fri Jul 22, 2011 2:43 am
by Corvin
Re: echoing something from multidimensional array
Posted: Fri Jul 22, 2011 2:47 am
by naggi
That was quick. Was just replying to my own post that I figured it out but thanks for the answer.