我想知道一个很好的方法来检查数组中的哪个元素是其开始/结束日期的前导元素(具有优先级)。
例如,这是数组:
(
[0] => Array
(
[ID] => 16
[begin_date] => DateTime Object
(
[date] => 2016-01-01
[timezone_type] => 3
[timezone] => UTC
)
[end_date] => DateTime Object
(
[date] => 2016-11-30
[timezone_type] => 3
[timezone] => UTC
)
)
[1] => Array
(
[ID] => 33
[begin_date] => DateTime Object
(
[date] => 2015-01-04
[timezone_type] => 3
[timezone] => UTC
)
[end_date] => DateTime Object
(
[date] => 2016-02-29
[timezone_type] => 3
[timezone] => UTC
)
)
)
在这种情况下,第二个元素具有优先权。因为它的begin_date早于第一个元素的begin_date。并且,它的end_date仍然在未来。
条件:
提前致谢!
答案 0 :(得分:-1)
uasort($memberArray,function($a,$b){
$c = $a['begin_date']['date'] - $b['begin_date']['date';
$c .= $a['overall']['PD'] - $b['overall']['PD'];
$c .= $a['overall']['PF'] - $b['overall']['PF'];
$c .= $a['overall']['W'] - $b['overall']['W'];
$c .= $a['overall']['MP'] - $b['overall']['MP'];
return $c;
});