[英]Parse error: syntax error, unexpected '[', expecting ')', possibly PHP version issue
My code is giving an error. 我的代码给出了错误。 I know now it has to do with the php version.
我知道现在它与php版本有关。 But to what should i change my code for it to work correctly?
但是我应该更改我的代码以使其正常工作吗?
$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;
Thanks 谢谢
The error is that you pass $post['tags']
to the function declaration. 错误是您将
$post['tags']
传递给函数声明。 You can change 你可以改变
$func = function($post['tags'])
...
to 至
$func = function($tags) {
$i=0;
while(!empty($tags)){
return $tags[$i]." ";
$i++;
}
}
and than call it as 然后称其为
$func($post['tags'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.