我的代码出错了。我现在知道这与php版本有关。但是,我应该如何修改代码才能正确工作呢?
$json = file_get_contents(
'https://api.instagram.com/v1/users/'. $user_id .'/media/recent/?client_id=' . $client_id . '&count=' . $count);
$decode = json_decode($json, true);
$output = '';
$func = function($post['tags']){
$i=0;
while(!empty($post['tags'])){
return $post['tags'][$i]." ";
$i++;
}
};
foreach ($decode['data'] as $post) {
$output .= $modx->getChunk($tpl,
array(
'link' => $post['link']
,'image' => $post['images']['standard_resolution']['url']
,'likes' => $post['likes']['count']
,'hashtags' => $func
)
);
}
return $output;谢谢
发布于 2015-11-17 15:58:16
错误是将$post['tags']传递给函数声明。你可以改变
$func = function($post['tags'])
...至
$func = function($tags) {
$i=0;
while(!empty($tags)){
return $tags[$i]." ";
$i++;
}
}而不是把它叫做
$func($post['tags'])https://stackoverflow.com/questions/33761346
复制相似问题