How to convert two dimensional array to one dimensional array in php?

前端 未结 6 1038
太阳男子
太阳男子 2021-02-01 11:17

I am Having an mutidimensional array getting result like given below

Array
(
    [0] => Array
        (
            [0] => 70
        )

    [1] => Arra         


        
6条回答
  •  -上瘾入骨i
    2021-02-01 11:59

    For a more generic function which can deal with multidimensional arrays, check this function,

    function  arrayFlattener($input = array(), &$output = array()) {
      foreach($input as $value) {
        if(is_array($value)) {
            arrayFlattener($value, $output);
        } else {
            $output[] = $value;
        }
      }
    }
    

    You can find an example here.

提交回复
热议问题