Combine two array and order this new array by date

后端 未结 3 1775
时光说笑
时光说笑 2021-02-19 13:58

. I have two array

First One

 Array
    (
        [0] => Array
            (
                [date] => 2012-01-10
                [result] => 65         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 14:25

    array_merge and usort is your friend.

    function cmp($a, $b){
        $ad = strtotime($a['date']);
        $bd = strtotime($b['date']);
        return ($ad-$bd);
    }
    $arr = array_merge($array1, $array2);
    usort($arr, 'cmp');
    

提交回复
热议问题