In the case of infinite classification, according to the id of the level-1 directory, it is necessary to read all the level-3 directories in the level-1 directory, and then read them in a foreach loop, there are five arrays, how can we merge them into an array? we used the array_merge () function, but the result is still five arrays, which are not successfully merged. {... Problems encountered during unlimited classification
Read all the level-3 directories in the level-1 directory based on the id of the level-1 Directory.
The foreach loop reads 5 arrays. how can we combine them into an array?
I used the array_merge () function, but the result is still five arrays. the merging is not successful.
Array (size = 3) 0 => array (size = 2) 'type _ name' => string 'oil-2 type' (length = 11) 'type _ id' => string '8' (length = 1) 1 => array (size = 2) 'type _ name' => string 'oil-3 type' (length = 11) 'type _ id' => string '9' (length = 1) 2 => array (size = 2) 'type _ name' => string 'oil-4 type' (length = 11) 'type _ id' => string '10' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips '(length = 12) 'type _ id' => string '20' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips 1' (length = 13) 'type _ id' => string '21' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips 1212 '(length = 16) 'type _ id' => string '22' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'oil pump 22 type' (length = 14) 'type _ id' => string '19' (length = 2)
Reply content:
Problems encountered during unlimited classification
Read all the level-3 directories in the level-1 directory based on the id of the level-1 Directory.
The foreach loop reads 5 arrays. how can we combine them into an array?
I used the array_merge () function, but the result is still five arrays. the merging is not successful.
Array (size = 3) 0 => array (size = 2) 'type _ name' => string 'oil-2 type' (length = 11) 'type _ id' => string '8' (length = 1) 1 => array (size = 2) 'type _ name' => string 'oil-3 type' (length = 11) 'type _ id' => string '9' (length = 1) 2 => array (size = 2) 'type _ name' => string 'oil-4 type' (length = 11) 'type _ id' => string '10' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips '(length = 12) 'type _ id' => string '20' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips 1' (length = 13) 'type _ id' => string '21' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'Phillips 1212 '(length = 16) 'type _ id' => string '22' (length = 2) array (size = 1) 0 => array (size = 2) 'type _ name' => string 'oil pump 22 type' (length = 14) 'type _ id' => string '19' (length = 2)
Usearray_merge()Function to merge multiple one-dimensional arrays.
I just read it wrong. these are all two-dimensional arrays. Then we can only assemble the array after foreach.
How many times have I checked the database? In fact, it can be detected once and then processed.
I don't know how to merge the data with the original one? Or is the structure you want not described as this?
'Oil-2', 'type _ id' => '8'], ['type _ name' => 'oil-2 ', 'type _ id' => '2'], ['type _ name' => 'oil-2 ', 'type _ id' => '3'],]; $ array2 = [['type _ name' => 'oil-2 ', 'type _ id' => '6'], ['type _ name' => 'oil-2 type ', 'type _ id' => '22'],]; $ arrays = array_merge ($ array1, $ array2); var_dump ($ arrays );