Rumah > pembangunan bahagian belakang > tutorial php > 数组 php array_multisort处置

数组 php array_multisort处置

WBOY
Lepaskan: 2016-06-13 13:02:31
asal
913 orang telah melayarinya

数组 php array_multisort处理


$money = array (
           0 =>array (        'money' => '21',    'time' => '2012-10-18', ),
           1 =>array (        'money' => '28',    'time' => '2012-10-17', ),
           2 =>array (        'money' => '92',    'time' => '2012-10-16', ),
           3 =>array (        'money' => '428',   'time' => '2012-10-15', ),
           4 =>array (        'money' => '776',    'time' => '2012-10-14',),
           5 =>array (        'money' => '298',    'time' => '2012-10-13',),
           7 =>array (        'money' => '112',    'time' => '2012-10-11',),
           8 =>array (        'money' => '199',     'time' => '2012-10-10',),
);

$money2 = array (
           0 =>array (   'gamemoney' => '2',   'time' => '2012-10-16',),
           1 =>array (   'gamemoney' => '50',   'time' => '2012-10-13',),
           2 =>array (   'gamemoney' => '75',   'time' => '2012-10-12',),
     );

require('Debug.php' );
foreach ($money as &$val ){
     $val['gamemoney']='';
}
foreach ($money2 as & $val2){
     $val2['money']='';
}
$times=array ();
foreach ($money as $key => $val3){
     array_push($times,$val3['time']);
}
foreach ($money2 as $key => $val4){
     if (in_array( $val4[ 'time'], $times)){
            $money_key =  array_search( $val4[ 'time'], $times);
            $money[$money_key ]['gamemoney' ] = $val4 ['gamemoney' ];
     }else{
     array_push($money, array( 'gamemoney'=> $val4[ 'gamemoney'], 'time'=> $val4[ 'time'], 'money'=> '') );
     }
}
foreach($money as $aaaaa){
     $timeaa[]=$aaaaa['time'];
}
array_multisort($timeaa,SORT_DESC, $money);


Zend_Debug::dump ($money );


Salin selepas log masuk


数组 php array_multisort处理

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan