Making multidimensional arrays single dimension

I have a an array that looks like this

array0( array1("values0"), array2("values1"))

What I can’t figure out is how I get the values from array2 in a new array or a foreach loop.

It’s probably quite obvious and I am just being slow today… :lol:

Thanks :slight_smile:

Found it. Completely obvious.

$newarray = array_values($array0[1]); 

Ok, I tried that. After the first foreach loop $sub contains the keys and values of array1() but I want array2().

How do I get that one?

Or, as a general function:

function array_flatten($array)
  foreach($array as $value)
    if (is_array($value))
       $newArray=array_merge($newArray, array_flatten($value));

Thanks loads to both of you.

It’s been a long day… :lol:

foreach ($array0 as $sub)
   foreach ($sub as $v)
           $newarray[] = $v;