Convert Double Dimensional Array to Single Dimensional in PHP

Convert Double Dimensional Array to Single Dimensional in PHP ? Huh, Some piece of codes come in handy, while we do programming. Converting a double dimensional array to single dimensional array is also like that.In this tutorial i am giving a simple piece of code to convert the double dimensional array to single dimensional array with an example.

I want to convert
Array ( [0] => Array ( [0] => 100 [1] => 101 ) )
to
Array ( [0] => 100 [1] => 101 )

To do this simply run on every element in dimensional array and take the values and push them values into new one, like this:

Code

$array_new = array();
foreach($array_old as $arr){
  foreach($arr as $elem){
     array_push($array_new, $elem);
  }
}

Also, you can apply the same logic in other languages too.It’s just a piece of code. I hope this article, Convert Double Dimensional Array to Single Dimensional in PHP. If you have any other doubts, comments etc drop them below.
Thanks for reading.