array multisort:数组 php array_multisort处理
程序员文章站
2022-04-02 18:08:06
...
$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 );
数组 php array_multisort处理 本文链接http://www.cxybl.com/html/wlbc/Php/20130504/37474.html
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 );
数组 php array_multisort处理 本文链接http://www.cxybl.com/html/wlbc/Php/20130504/37474.html
上一篇: PHP实现定时任务的几种处理方法
下一篇: php如何将数组转js数组
推荐阅读
-
PHP数组函数array_multisort()用法实例分析
-
PHP计算数组中值的和与乘积的方法(array_sum与array_product函数)
-
php二维数组排序方法(array_multisort usort)
-
PHP使用array_merge重新排列数组下标的方法
-
php数组合并array_merge()函数使用注意事项
-
PHP字符串与数组处理函数用法小结
-
php利用array_search与array_column实现二维数组查找
-
php array_map array_multisort 高效处理多维数组排序
-
PHP中的array数组类型分析说明
-
php使用array_rand()函数从数组中随机选择一个或多个元素