thinkphp Array Merging

Source: Internet
Author: User
Problems encountered in doing infinite classification
All level three directories contained in the first level directory are read out according to the ID of the primary directory
After the Foreach loop is read 5 arrays, how can it be merged into an array?
The Array_merge () function was used, but the result was 5 arrays, and no merge succeeded.

  Array (size=3) 0 = = Array (size=2) ' type_name ' = = String ' Oil-type 2  ' (length=11) ' type_id ' = = String ' 8 ' (length=1) 1 = = Array (size=2) ' type_name ' = = String ' Oil-type 3 '      (length=11) ' type_id ' = = String ' 9 ' (length=1) 2 = = Array (size=2) ' type_name ' + string ' oil-type 4 ' (length=11) ' type_id ' = ' + String ' (length=2) array (size=1) 0 + = Array (size=2) ' type_name ' = = String ' Phillips ' (Leng  th=12) ' type_id ' = = String ' (length=2) array (size=1) 0 = = Array (size=2) ' type_name ' = = string ' Phillips 1 ' (length=13) ' type_id ' = + string ' (length=2) array (size=1) 0 = = Array (size=2) ' Type_name ' = = String ' Phillips 1212 ' (length=16) ' type_id ' = ' + String ' (length=2) array (size=1) 0 = = Array (size=2 ) ' type_name ' + string ' petrol pump Type 22 ' (length=14) ' type_id ' = ' + String ' (length=2)  

Reply content:

Problems encountered in doing infinite classification
All level three directories contained in the first level directory are read out according to the ID of the primary directory
After the Foreach loop is read 5 arrays, how can it be merged into an array?
The Array_merge () function was used, but the result was 5 arrays, and no merge succeeded.

  Array (size=3) 0 = = Array (size=2) ' type_name ' = = String ' Oil-type 2  ' (length=11) ' type_id ' = = String ' 8 ' (length=1) 1 = = Array (size=2) ' type_name ' = = String ' Oil-type 3 '      (length=11) ' type_id ' = = String ' 9 ' (length=1) 2 = = Array (size=2) ' type_name ' + string ' oil-type 4 ' (length=11) ' type_id ' = ' + String ' (length=2) array (size=1) 0 + = Array (size=2) ' type_name ' = = String ' Phillips ' (Leng  th=12) ' type_id ' = = String ' (length=2) array (size=1) 0 = = Array (size=2) ' type_name ' = = string ' Phillips 1 ' (length=13) ' type_id ' = + string ' (length=2) array (size=1) 0 = = Array (size=2) ' Type_name ' = = String ' Phillips 1212 ' (length=16) ' type_id ' = ' + String ' (length=2) array (size=1) 0 = = Array (size=2 ) ' type_name ' + string ' petrol pump Type 22 ' (length=14) ' type_id ' = ' + String ' (length=2)  

Use array_merge() a function to merge multiple one-dimensional arrays.

Just read the wrong, originally these are two-dimensional array ah. It is only possible to assemble the arrays after the foreach.

Master, how many times did you check the database? Can actually be detected at once, and then processed.
Do not know how the landlord to do after the merger or the same as the original? Or does the landlord want the structure that you describe?


  
    '机油-2型',        'type_id' => '8'    ],    [        'type_name' => '机油-2型',        'type_id' => '2'    ],    [        'type_name' => '机油-2型',        'type_id' => '3'    ],];$array2 = [    [        'type_name' => '机油-2型',        'type_id' => '6'    ],    [        'type_name' => '机油-2型',        'type_id' => '22'    ],];$arrays = array_merge($array1, $array2);var_dump($arrays);
  • 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.