0
Is it possible to transform a Multidimensional array into just 1 (one) array in php? What would the process be like to do this?
In the image below, I need to transform the array on the left side so that the records are equal to the right side, I tried with the array_merge but it doesn’t work, someone knows otherwise?
It is not possible because the PHP does not accept a array with two or more equal indices.
– Valdeir Psr
And if I changed the name of the indexes so that I did not become equal, like id1, id2, id3, etc... It would be possible so?
– Jorgito da Silva Paiva
What is the reason to unite the arrays? In my view, it will only be difficult to manipulate it.
– Gabriel Heming
@Jorgitodasilvapaiva Yes, it is possible, just use a
foreach
to traverse the first array and go creating a new array with the values.– Valdeir Psr
The reason to join the arrays will be to join an array that will always return 4 rows of records from a database query to another array that will have the other data in just one row and unite everything to stay in just one line, is the idea clear? I tried to do this with foreach but it didn’t work.
– Jorgito da Silva Paiva
@Valdeir Psr if you can demonstrate the structure of this foreach I thank you.
– Jorgito da Silva Paiva