提前感谢您的帮助!我是 php 的绝对新手,但正在努力相处。
我有一个数组 $result ,其中包含以下内容:
Array
(
[0] => Array
(
[id] => xyz
[from] => Array
(
[name] => xyz
[id] => xyz
)
[link] => xyz
[name] => xyz
[picture] => xyz
[created_time] => xyz
)
[1] => Array
(
[id] => xyz
[from] => Array
(
[name] => xyz
[id] => xyz
)
[link] => xyz
[name] => xyz
[picture] => xyz
[created_time] => xyz
)
等等... 。
我想要实现的是一个适用于其中一些信息的 foreach 循环。现在我更改了代码以简单地输出信息,所以我可以看到问题......我想。我的代码是:
foreach($result AS $buildresult) {
$resobjid = array_column($buildresult, 'id');
$cardpicurl = "https://graph.facebook.com/$resobjid/picture";
$heading = array_column($buildresult ['from'], 'name');
$para = array_column($buildresult, 'name');
$link = array_column($buildresult, 'link');
echo '<pre>' . print_r( $resobjid, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $cardpicurl, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $heading, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $para, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $link, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $cardpicurl, 1 ) . '</pre><br>';
echo '<pre>' . print_r( $buildresult, 1 ) . '</pre><br>';
}
我期待它做类似的事情:
The ID
https://graph.facebook.com/someidfromthearray/picture
Array
(
[0] => Some Name from the Array
)
Array
(
[0] => Some Name from the above array
)
但我得到的是:
Array
(
[0] => 387639951329150
)
https://graph.facebook.com/Array/picture
Array
(
)
Array
(
[0] => Some.Name
)
Array
(
)
https://graph.facebook.com/Array/picture
所以我确实从“来自”数组中获取了 ID 和名称。其余的似乎是空的。尽管在其中正确显示,但也https://graph.facebook.com/$resobjid/picture
显示“阵列”echo '<pre>' . print_r( $resobjid, 1 ) . '</pre><br>';
非常感谢任何帮助!
非常感谢!:)