我还在学习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
array(8){[0] => string(9)“site_name”[1] => string(3)“url”[2] => string(5)“title”[3] => string(11)“description”[4] =>串(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 =>什么样的现代社会原型适合你的个性?description =>这是2017年,所以现在是我们更新书籍的时候了!type => articleimage => http://cdn.playbuzz.com/cdn/aef166e1-1574-4d57-9823-3f38f30bcfc4/810f1d3e-0a97-4797-8235-b4c988562a1c.jpgimage:width => 1600image:height => 842
我正在尝试仅回显description
It's 2017, so it's about time we update the books!
我尝试过几种不同的东西,但没有任何作用。非常感谢任何帮助。
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'];
?>
答案 0 :(得分:1)
如果密钥已存在,您的代码似乎可以直接从$graph
获取描述值。
你也试图在这里展示$array['description'];
我可以看到$ array定义任何地方
尝试
echo $graph['description']; // if $graph is array
OR
echo $graph->description; // If its an object
答案 1 :(得分:0)
致电
echo $array[3];
或者使用可以被称为
的关联数组echo $array['description'];