我有这个数组
阵列的print_r
Array (
[@attributes] => Array (
[from] => 14073377593@s.whatsapp.net
[id] => 1346984983-2
[type] => chat
[t] => 1346985039
)
[notify] => Array (
[@attributes] => Array (
[name] => SISTEMA SMS
)
)
[request] => Array ( )
[body] => Hola
)
我需要这个值
[body] => Hola
有人可以帮我
echo $array['body'];
你试过什么了吗?
作为一个多维数组,body
属性位于第一层:
Array (
[@attributes] => Array (
[from] => 14073377593@s.whatsapp.net
[id] => 1346984983-2
[type] => chat
[t] => 1346985039
)
[notify] => Array (
[@attributes] => Array (
[name] => SISTEMA SMS
)
)
[request] => Array ( )
[body] => Hola
)
因此,作为一个提示,用<pre>
HTML标记包装您的print_r
调用,以便读取正确格式的输出:
echo '<pre>';
print_r($stuff);
echo '</pre>';
这可能看起来很傻,但它为我节省了很多时间。
它位于$array["body"]
请看一下这样的内容,了解关联数组的旋风之旅:http://phpjournal.blogspot.co.uk/2004/11/php-associative-arrays.html