Convert array of single-element arrays to a one-dimensional array

For your limited use case, this’ll do it:

$oneDimensionalArray = array_map('current', $twoDimensionalArray);

This can be more generalized for when the subarrays have many entries to this:

$oneDimensionalArray = call_user_func_array('array_merge', $twoDimensionalArray);

Leave a Comment