PHP Array Flatten?

by 2 replies
3
Is there a way to pull only the values out of a multidimensional array?

I have a big mess of an array like this:
Array ( [0] => Array ( [0] => Array ( [0] => VALUE ) [1] => Array ( [0] => VALUE ) ) [1] => Array ( [0] => Array ( ) [1] => Array ( ) ) [2] => Array ( [0] => Array ( ) [1] => Array ( ) ) [3] => Array ( [0] => Array ( ) [1] => Array ( ) ) [4] => Array ( [0] => Array ( ) [1] => Array ( ) ) [5] => Array ( [0] => Array ( ) [1] => Array ( ) ) [6] => Array ( [0] => Array ( [0] => VALUE ) [1] => Array ( [0] => VALUE ) ) )

I just want to rip the values out and place them in a new array, but there doesn't seem to be a function for that. Is there?
#programming #array #flatten #php
  • it wont be a mess if you look at it in the source code, it will be nicely laid out.

    or you can put <pre></pre> tags around your array printing device to make it look pretty.

    as for bringing it all back down to a single-dimention array your going to need to do some looping with 'foreach' loops to open each array then put them into a new single storage array.

    This _might_ be the answer your looking for:
    How to "flatten" a multi-dimensional array to simple one in php? - Stack Overflow

    otherwise its build a custom loop time.
    • [ 1 ] Thanks
  • Thanks for the help..It was what I was looking for...

Next Topics on Trending Feed