1,">
时间:2021-07-01 10:21:17 帮助过:4人阅读
$arr1 = array("0"=>1,'1'=>20,'2'=>37,'3'=>43);
$arr2 = array('0'=>array('times'=>'2014-02-25','counts'=>'19'),'1'=>array('times'=>'2014-02-26','counts'=>'17'),'2'=>array('times'=>'2014-02-27','counts'=>'6'),'3'=>array('times'=>'2014-02-28','counts'=>'8'));
$arr = array_intersect_key($arr2,$arr1);
foreach ($arr2 as $key => $value) {
$arr2[$key]['incnum'] = $arr1[$key];
unset($arr2[$key]['counts']);
}
var_dump($arr2);
$a = array(1,20,37,43);
$b = array(array('times'=>'2014-02-25','counts'=>'19'),array('times'=>'2014-02-26','counts'=>'17'),array('times'=>'2014-02-27','counts'=>'6'),array('times'=>'2014-02-28','counts'=>'8'));
$c = array();
for($i=0,$len=count($a); $i<$len; $i++){
array_push($c, array('times'=>$b[$i]['times'],'incnum'=>$a[$i]));
}
var_dump($c);
?>
$a = array(1,20,37,43);
$b = array(array('times'=>'2014-02-25','counts'=>'19'),array('times'=>'2014-02-26','counts'=>'17'),array('times'=>'2014-02-27','counts'=>'6'),array('times'=>'2014-02-28','counts'=>'8'));
$c = array_map(function($a, $b) { return array('times'=>$b['times'],'incnum'=>$a); }, $a, $b);
var_dump($c);