Convert multidimensional array into single array

后端 未结 20 1600
时光取名叫无心
时光取名叫无心 2020-11-22 10:39

I have an array which is multidimensional for no reason

/* This is how my array is currently */
Array
(
[0] => Array
    (
        [0] => Array
                


        
20条回答
  •  难免孤独
    2020-11-22 11:12

    If you come across a multidimensional array that is pure data, like this one below, then you can use a single call to array_merge() to do the job via reflection:

    $arrayMult = [ ['a','b'] , ['c', 'd'] ];
    $arraySingle = call_user_func_array('array_merge', $arrayMult);
    // $arraySingle is now = ['a','b', 'c', 'd'];
    

提交回复
热议问题