需要将多维数组转换为充满数值的普通数组php



我在数组中遇到了一些困难,我的多维数组结果如下

Array ( 
  [0] => Array ( 
      [0] => 111 
      [1] => 112 ) 
  [1] => 
  [2] => Array ( 
      [0] => 116 ) 
  [3] => Array ( 
      [0] => 113 
      [1] => 114 ) 
  [4] => Array ( 
      [0] => 96 
      [1] => 97 ) 
  [5] => ) 

需要作为的结果

array(          [0] => 96
                [1] => 97
                [2] => 111
                [3] => 112
                [4] => 113
                [5] => 114
                [6] => 116
)
  $a = array_filter( $arr);                       // remove empty items
  $a = array_reduce($a, 'array_merge',array());   // flaten array
  sort($a);                                       // sort it

结果

Array
(
    [0] => 96
    [1] => 97
    [2] => 111
    [3] => 112
    [4] => 113
    [5] => 114
    [6] => 116
)

相关内容

  • 没有找到相关文章

最新更新