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);