【发布时间】:2018-04-24 16:11:31
【问题描述】:
有没有办法将 array_multisort 与自定义 order by 一起使用?我需要按日期顺序显示结果,第一个日期是最接近今天的日期,正如您从下面的代码中看到的那样,matchDate 字段作为字符串出现,我稍后将其转换为日期值。
foreach($matchLists as $matchList)
{
$fixtures[] = $matchList['matchDate'];
}
array_multisort($fixtures, SORT_DESC, $matchLists);
$newlist = array();
foreach($matchLists as $key => $matchitem)
{
if(array_key_exists('matchDate', $matchitem))
{
$newlist[$matchitem['matchDate']][$key] = ($matchitem);
}
}
foreach($newlist as $key => $value)
{
$fixtureDate = date('D j M Y ga', strtotime($key));
}
【问题讨论】:
标签: php arrays array-multisort