Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中特定于echo的数组部分_Php_Arrays_Multidimensional Array_Echo - Fatal编程技术网

php中特定于echo的数组部分

php中特定于echo的数组部分,php,arrays,multidimensional-array,echo,Php,Arrays,Multidimensional Array,Echo,我仍然在学习php数组,我正在尝试回显一个 array(8) { [0]=> string(9) "site_name" [1]=> string(3) "url" [2]=> string(5) "title" [3]=> string(11) "description" [4]=> string(4) "type" [5]=> string(5) "image" [6]=> string(11) "image:width" [7]=> stri

我仍然在学习php数组,我正在尝试回显一个

array(8) { [0]=> string(9) "site_name" [1]=> string(3) "url" [2]=> string(5) "title" [3]=> string(11) "description" [4]=> string(4) "type" [5]=> string(5) "image" [6]=> string(11) "image:width" [7]=> string(12) "image:height" } NULL site_name => Playbuzzurl => http://www.playbuzz.com/jordonr10/what-modern-societal-archetype-fits-your-personalitytitle => What Modern Societal Archetype Fits Your Personality?description => It's 2017, so it's about time we update the books!type => articleimage => http://cdn.playbuzz.com/cdn/aef166e1-1574-4d57-9823-3f38f30bcfc4/810f1d3e-0a97-4797-8235-b4c988562a1c.jpgimage:width => 1600image:height => 842
数组(8){[0]=>string(9)“站点名称”[1]=>string(3)“url”[2]=> 字符串(5)“标题”[3]=>字符串(11)“说明”[4]=>字符串(4) “键入”[5]=>string(5)“图像”[6]=>string(11)“图像:宽度”[7]=> 字符串(12)“image:height”}NULL site_name=>playbushURL=> =>什么样的现代社会原型适合你的个性?描述=>现在是2017年,是我们更新书籍的时候了!类型=>articleimage =>=>1600图像:高度=>842

我只是想回应一下
description
的值,也就是
现在是2017年,所以是时候更新书籍了

我试过几种不同的方法,但都不管用。非常感谢您的帮助

echo $array[0]['description'];      // returns nothing
var_dump($key);                     // returns string(12) "image:height"
当前代码

<?php
require_once('OpenGraph.php');

$graph = OpenGraph::fetch('http://www.playbuzz.com/jordonr10/what-modern-societal-archetype-fits-your-personality');
var_dump($graph->keys());
var_dump($graph->schema);

foreach ($graph as $key => $value) {
    echo "$key => $value<br><hr>";
}
echo "Value Below<hr>";
echo $array['description'];

?>

只要打电话

echo $array[3];
或者使用可以调用的关联数组

echo $array['description'];

从您的代码中,似乎可以直接从
$graph
中获取描述值,前提是键已经存在。 另外,您正在尝试diplay
$array['description']在这里我可以看到$array是定义任意位置的

设法

 echo $graph['description']; // if $graph is array


描述的值不在数组中。您需要先将其放入数组中,然后才能获取它。在此处显示您使用的代码。嘿,justyand,感谢您提供的帮助。我也试过这两种方法,但都不管用。还有其他想法吗?没问题。首先放置代码。然后我们可以讨论故障。Basicali首先定义一个数组,然后调用echo@Mr.B您的问题没有意义,请阅读问题下的第一条注释。因此,从代码中可以明显看出,$array没有定义,您必须使用$graphIt作为对象。这就解释了为什么我所尝试的一切都失败了。如何区分上面提到的对象和数组之间的区别?再次感谢!使用
var\u dump($graph)结果将显示它是对象还是数组
echo $graph->description; // If its an object