<?php
$arr=array(
array("count"=>10,"date"=>"2014-04-16"),
array("count"=>50,"date"=>"2014-04-18"),
array("count"=>80,"date"=>"2014-04-20")
);
$date =array("2014-04-16","2014-04-17","2014-04-18","2014-04-19","2014-04-20");
foreach($arr as $val){
$new_arr[$val['date']] = $val['count'];
}
foreach($date as $key => $val){
$result[$key]['count'] = isset($new_arr[$val]) ? $new_arr[$val] : 0;
$result[$key]['date'] = $val;
}
print_r($result);
//对应$date所有日期转换为
$arr=array(
array("count"=>10,"date"=>"2014-04-16"),
array("count"=>0,"date"=>"2014-04-17"),
array("count"=>50,"date"=>"2014-04-18"),
array("count"=>0,"date"=>"2014-04-19"),
array("count"=>80,"date"=>"2014-04-20"),
)
- Output for 5.4.0 - 5.4.27
- Parse error: syntax error, unexpected end of file in /in/FmMMs on line 34
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected $end in /in/FmMMs on line 34
Process exited with code 255.
preferences:
190.29 ms | 1395 KiB | 64 Q