php 数组合并的问题? 400 报错
先谢谢各位了
已知
$arr1 = array("1月","3月","4月");
$arr1date=array("100","200","300");
$arr2 = array("1月","2月","5月");
$arr2date=array("300","400","500");
求
$arr3 =array("1月","2月","3月","4月","5月");
$arr1date1=array("100","0","200","300","0");
$arr2date1=array("300","400","0","0","500");
<?php $arr1 = array("1月","3月","4月"); $arr1date=array("100","200","300"); $arr2 = array("1月","2月","5月"); $arr2date=array("300","400","500"); $arr3 =array("1月","2月","3月","4月","5月"); $a1 = array_combine($arr1,$arr1date); $a2 = array_combine($arr2,$arr2date); $arr1date1 = $arr1date2 =array(); foreach ($arr3 as $v){ if(isset($a1[$v])){ $arr1date1[] = $a1[$v]; }else{ $arr1date1[] = "0"; } if(isset($a2[$v])){ $arr2date1[] = $a2[$v]; }else{ $arr2date1[] = "0"; } } print_r($arr1date1); print_r($arr2date1); ?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。