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

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

I am Having an mutidimensional array getting result like given below

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

    [1] => Arra         


        
6条回答
  •  生来不讨喜
    2021-02-01 11:56

    By using this function you can convert any dimension array into a single dimention array.

    $result = array();
    $data = mearchIntoarray($result,$array);
    function mearchIntoarray($result,$now)
    {
        global $result;
        foreach($now as $key=>$val)
        {
            if(is_array($val))
            {
                mearchIntoarray($result,$val);
            }
            else
            {
                $result[] = $val;
            }
        }
        return $result;
    } 
    

    Where $array is your given array value.

提交回复
热议问题