SBF胜博发娱乐老虎机php数组合并

( SBF胜博发娱乐老虎机 )

有三个一维数组,
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)

array( [orderno] => 2321 [deliverysn] => 444 [deliverycorpname] => wqwq )  一次类推怎么做

不知道题主是不是这个意思,效果如下
https://3v4l.org/8r0ko

//首先要确定这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);

foreach($arr_a as $k=>$v){
    $arr_{$k}['orderno'] = $v;
    $arr_{$k}['deliverysn'] = $arr_b[$k];
    $arr_{$k}['deliverycorpname'] = $arr_c[$k];
}

$arr_key = ['orderno', 'deliverysn', 'deliverycorpname'];
$map_arr=array_map(null,$arr_orderno,$arr_deliverysn,$arr_deliverycorpname);
$res=array_map(function($i) use($arr_key){
return array_combine($arr_key,$i);
},$map_arr);
/*
[
     [
       "orderno" => 12321,
       "deliverysn" => 7,
       "deliverycorpname" => "asd",
     ],
     [
       "orderno" => 321,
       "deliverysn" => 8,
       "deliverycorpname" => "qwe",
     ],
     [
       "orderno" => 321,
       "deliverysn" => 9,
       "deliverycorpname" => "zxc",
     ],
   ]
*/

(看完/读完)这篇文章有何感想! SBF胜博发娱乐老虎机的分享…

发表评论

电子邮件地址不会被公开。 必填项已用*标注