I want to add sub arrays to one single array in php [duplicate]

半城伤御伤魂 提交于 2019-11-30 05:24:59

Try this :

$array  = your array

$result = call_user_func_array('array_merge', $array);

echo "<pre>";
print_r($result);

Or try this :

function array_flatten($array) {

   $return = array();
   foreach ($array as $key => $value) {
       if (is_array($value)){ $return = array_merge($return, array_flatten($value));}
       else {$return[$key] = $value;}
   }
   return $return;

}

$array  = Your array

$result = array_flatten($array);

echo "<pre>";
print_r($result);

try this.....

       $result = array();
        foreach($data  as $dat)

          {
                foreach($dat as $d) 

                 {
                   $result[] = $d;

                 }

           }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!