Sometimes, we want to convert a multidimensional array into single array with PHP.
In this article, we’ll look at how to convert a multidimensional array into single array with PHP.
How to convert a multidimensional array into single array with PHP?
To convert a multidimensional array into single array with PHP, we can use the array_column
function.
For instance, we write
$array = array_column($array, "plan");
to call array_column
with $array
and 'plan'
to take the entry with 'plan'
as the key from each array in $array
and return a new array with the values of them.
Conclusion
To convert a multidimensional array into single array with PHP, we can use the array_column
function.