有三个一维数组,array ( [0] => 12312 [1] => 2321 [2] => 12321 ) array ( [0] => 133 [1] => 444 [2] => 888 ) array ( [0] => qqqqqqq [1] => wqwq [2] => wqe )
合并成array( [orderno] => 12312 [deliverysn] => 133 [deliverycorpname] => qqqqqqq)
<code>array( [orderno] => 2321 [deliverysn] => 444 [deliverycorpname] => wqwq ) 一次类推怎么做</code>
有三个一维数组,array ( [0] => 12312 [1] => 2321 [2] => 12321 ) array ( [0] => 133 [1] => 444 [2] => 888 ) array ( [0] => qqqqqqq [1] => wqwq [2] => wqe )
合并成array( [orderno] => 12312 [deliverysn] => 133 [deliverycorpname] => qqqqqqq)
<code>array( [orderno] => 2321 [deliverysn] => 444 [deliverycorpname] => wqwq ) 一次类推怎么做</code>
不知道题主是不是这个意思,效果如下
https://3v4l.org/8r0ko
立即学习“PHP免费学习笔记(深入)”;
<code class="php">//首先要确定这3个数组是关联数组和所包含的元素个数都是一样的
$arr_orderno = [12321,321,321];
$arr_deliverysn = [7,8,9];
$arr_deliverycorpname = ['asd','qwe','zxc'];
$arr_merge= [];
for($i = 0; $i < count($arr_orderno); $i++){
$arr_merge[$i] = [$arr_orderno[$i], $arr_deliverysn[$i], $arr_deliverycorpname[$i]];
}
$arr_key = ['orderno', 'deliverysn', 'deliverycorpname'];
$arr = [];
foreach ($arr_merge as $value) {
$arr[] = array_combine($arr_key, $value);
}
print_r($arr);</code>
<code>foreach($arr_a as $k=>$v){
$arr_{$k}['orderno'] = $v;
$arr_{$k}['deliverysn'] = $arr_b[$k];
$arr_{$k}['deliverycorpname'] = $arr_c[$k];
}</code>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号