Accessing array elements in PHP
Posted
by
Elliot B.
on Stack Overflow
See other posts from Stack Overflow
or by Elliot B.
Published on 2012-06-10T04:23:20Z
Indexed on
2012/06/10
4:40 UTC
Read the original article
Hit count: 121
php
I have an array $aMethods whose print_r output is this:
Array
(
[0] => Array
(
[pattern] =>
[return_media] => 1
[return_name] =>
)
)
I'm trying to access 'return_media' with this code:
$iReturnMedia = $aMethods[0]->return_media;
echo $iReturnMedia;
Also, when I tried this:
$iReturnMedia = $aMethods[0]['return_media'];
I get an error stating: Cannot use string offset as an array in...
But it's not working, $iReturnMedia comes back as blank. Could someone tell me what I'm doing wrong here?
© Stack Overflow or respective owner