PHP Array Merging

Source: Internet
Author: User
There are three one-dimensional arrays,
Array ( [0] => 12312 [1] => 2321 [2] => 12321 )
Array ( [0] => 133 [1] => 444 [2] => 888 )
Array ( [0] => qqqqqqq [1] => wqwq [2] => wqe )

Merged into
array( [orderno] => 12312 [deliverysn] => 133 [deliverycorpname] => qqqqqqq)

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

Reply content:

There are three one-dimensional arrays,
Array ( [0] => 12312 [1] => 2321 [2] => 12321 )
Array ( [0] => 133 [1] => 444 [2] => 888 )
Array ( [0] => qqqqqqq [1] => wqwq [2] => wqe )

Merged into
array( [orderno] => 12312 [deliverysn] => 133 [deliverycorpname] => qqqqqqq)

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

Do not know the main question is not the meaning, the effect is as follows
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];}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.