I am new to php (learning since 1 week ). I am learning arrays. while doing it, I found a api which gives out results in the form of a multidimensional array.. and I am unable to echo the values of the array ..
Sample response
Array
(
[query] => Array
(
[count] => 1
[created] => 2010-07-16T08:35:38Z
[lang] => en-US
[results] => Array
(
[item] => Array
(
[rel] => rel:Person
[resource] => http://twitter.com/twitter
[meta] => Array
(
[0] => Array
(
[property] => foaf:name
[content] => Twitter
)
)
)
)
)
)
I can echo some values..like
echo $array["query"]['count']."<br />";
echo $array["query"]["results"]["item"]["resource"];
but, when I want to use the [meta] => Array
I am not able to use :(
echo $array["query"]["results"]["item"]["resource"]["meta']["0"["content"];
please guide me
You should use your debugging skills to tackle this kind of problem.
print_r()
your $array, which you did.print_r($array['query'])
print_r($array['query']['results'])
When you get to print_r($array["query"]["results"]["item"]["resource"])
, you see that the result is not an array, it's a scalar, thus you need a different index.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With