首页 > php教程 > php手册 > 正文

array multisort:数组 php array_multisort处理

WBOY
发布: 2016-06-21 08:50:04
原创
1102 人浏览过

$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



相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!