分析错误:语法错误,意外';[';,预期为';';,可能是PHP版本问题

分析错误:语法错误,意外';[';,预期为';';,可能是PHP版本问题,php,api,object,instagram,Php,Api,Object,Instagram,我的代码出了一个错误。我现在知道这与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 =

我的代码出了一个错误。我现在知道这与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;

谢谢

错误在于您将
$post['tags']
传递给函数声明。您可以更改

$func = function($post['tags'])
...

并称之为

$func($post['tags'])

我以前从未见过“arse”错误:')我在JamieSterling见过几个arse!“arse error”是英国的。美国人是“ass fault”。最有可能的是php版本可能与
$func($post['tags'])