array multisort:数组 php array_multisort处理
程序员文章站
2022-03-24 22:46:52
...
$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数组相加 array(“a”)+array(“b”)结果还是array(“a”)_PHP
-
php关于array_multisort多维数组排序的使用说明_php技巧
-
php二维数组处理
-
PHP array_multisort() 函数的深入解析_PHP
-
解析array splice的移除数组中指定键的值,返回一个新的数组_PHP
-
第4章 数据处理-php数组的处理-郑阿奇_php入门_脚本之家
-
php通过array_merge()函数合并关联和非关联数组的方法_PHP教程
-
array_multisort实现PHP多维数组排序示例讲解_php技巧
-
PHP实现数组array转换成xml的方法
-
数组 - 迅搜产出包含特殊object的array转化成一般PHP array