PHP多个一维数组合并成二维数组的简易方法
2021-03-03 16:28
标签:order request min bsp str 转换 mic 需要 src 当我们需要进行数组遍历数据的时候,需要将多个一维数组进行二维的转换,方法很简单。如下: 转载 :https://www.cnblogs.com/wenzheshen/p/7120028.html ---------------------------------------------------------------自己项目--------------------------------------------------------------------- $total_amount_arr = $param[‘total_amount‘]; $StudentOrderListModel = new \app\admin\model\StudentOrderList(); dump($total_amount_arr); } 组成的新数组 PHP多个一维数组合并成二维数组的简易方法 标签:order request min bsp str 转换 mic 需要 src 原文地址:https://www.cnblogs.com/yehuisir/p/14385975.htmlphp
$a= array(‘张三‘,‘李四‘,‘王五‘);
$b= array (‘23‘,‘24‘,‘25‘);
$c= array (‘北京‘,‘上海‘,‘广州‘ );
foreach($a as $key=>$val){ $d[$key][‘姓名‘]=$a[$key];
$d[$key][‘年龄‘]=$b[$key];
$d[$key][‘城市‘]=$c[$key];
}
echo "pre";
var_dump($d);
?>
$param = $this->request->param(‘‘);
$student_order_list_id_arr = $param[‘student_order_list_id‘];
dump($student_order_list_id_arr);
foreach($student_order_list_id_arr as $key => $val){
$d[$val]=$total_amount_arr[$key];
dump($d);die;array(3) {
[0] => string(2) "24"
[1] => string(3) "543"
[2] => string(4) "7657"
}
array(3) {
[0] => string(1) "1"
[1] => string(1) "2"
[2] => string(1) "3"
}
array(3) {
[1] => string(2) "24"
[2] => string(3) "543"
[3] => string(4) "7657"
}
上一篇:Java程序员能力大纲
下一篇:python如何离线安装第三方库
文章标题:PHP多个一维数组合并成二维数组的简易方法
文章链接:http://soscw.com/index.php/essay/59592.html