Convert Double Dimensional Array to Single Dimensional in PHP

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

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.

Leave a Comment

Your email address will not be published. Required fields are marked *