我知道存在类似的线程,并且我尝试理解并阅读它们,但我没有任何进展。
问题:我想输出斯坦利·库布里克执导的所有电影,并且希望电影按上映年份降序排列。
电影的输出有效,但我无法对它们进行排序。
到目前为止我的代码
$data = file_get_contents($url); // put the contents of the file into a variable
$director = json_decode($data); // decode the JSON feed
echo '<pre>';
print_r($director);
foreach ($director->crew as $showDirector) {
if ($showDirector->department == 'Directing') {
usort($showDirector, function ($item1, $item2) {
return $item2['release_date'] <=> $item1['release_date'];
});
echo $showDirector->release_date . ' / ' . $showDirector->title . '<br>';
}
}
三国纷争