I have an array which is multidimensional for no reason
/* This is how my array is currently */
Array
(
[0] => Array
(
[0] => Array
(
[plan] => basic
)
[1] => Array
(
[plan] => small
)
[2] => Array
(
[plan] => novice
)
[3] => Array
(
[plan] => professional
)
[4] => Array
(
[plan] => master
)
[5] => Array
(
[plan] => promo
)
[6] => Array
(
[plan] => newplan
)
)
)
I want to convert this array into this form
/*Now, I want to simply it down to this*/
Array (
[0] => basic
[1] => small
[2] => novice
[3] => professional
[4] => master
[5] => promo
[6] => newplan
)
Any idea how to do this?
For this particular case, this'll do:
It's basically the exact same question is this one, look at some answers there: PHP array merge from unknown number of parameters.
this is best way to create a array from multiDimensionalArray array.
thanks
The first argument is an array | The second argument is array key.
Note: array_column was introduced in PHP 5.5 so it won't work in earlier versions.
Multi dimensional array to single array with one line code !!! Enjoy the code.
...Enjoy the code.
Save this as a php file, simply import and use single_array() function
I have done this with OOP style