I have an array that looks like this:
Array ( [0] => stdClass Object ( [user_id] => 10 [date_modified] => 2010-07-25 01:51:48 ) [1] => stdClass Object ( [user_id] => 16 [date_modified] => 2010-07-26 14:37:24 ) [2] => stdClass Object ( [user_id] => 27 [date_modified] => 2010-07-26 16:49:17 ) [3] => stdClass Object ( [user_id] => 79 [date_modified] => 2010-08-08 18:53:20 ) )
and what I need to do is print the user id, divided like this:
10, 16, 27, 79
I assume this will be in a for loop, but I'm looking for the most efficient way to do this in PHP
Oh and array name: $ mArray
I tried this:
foreach($mArray as $k => $cur) { echo $cur['user_id']; echo ','; }
which others have suggested.
However, I keep getting this error:
Fatal error: you cannot use an object of type stdClass as an array.
I think because this array is not a typical array, so it requires a different syntax?
source share