i have an array that looks like this:
foreach($obj as $key => $value)
{
print_r ($obj);
}
Array
(
[id] => 24991526504444
[name] => 21test
[picture] => http://profile.ak.fbcdn.net/hprofile-ak-sn4/276505_2499152255_s.jpg
[link] => http://apps.facebook.com/test/vote=6189373
[likes] => 1
[category] => Website
[parking] => Array
(
[street] => 0
[lot] => 0
[valet] => 0
)
[payment_options] => Array
(
[cash_only] => 0
[visa] => 0
[amex] => 0
[mastercard] => 0
[discover] => 0
)
)
how can i get the data from this array, for ex the id, or the likes.
i’ve tryed echo $key['likes'] or echo $key[$value['likes']] and some more combinations and it doesn’t work
any ideas?
thanks
$keyisn’t your array,$objis your array. You should be using$obj['likes']or$obj['parking']['street']. You don’t have to enumerate the keys to access the keys/values within the object, just use$obj.Also, your
foreachdoesn’t make sense:This reads “For each key in the array, print the entire array”. You don’t have to loop at all, the whole purpose of
print_ris to recursively print the contents of an array for you with no looping. Just use