-4

i face some difficult in arrays my multidimensional array result is like this

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] => ) 

need result as

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

)
splash58
  • 26,043
  • 3
  • 22
  • 34
puvi
  • 1
  • 1

1 Answers1

1
  $a = array_filter( $arr);                       // remove empty items
  $a = array_reduce($a, 'array_merge',array());   // flaten array
  sort($a);                                       // sort it

result

Array
(
    [0] => 96
    [1] => 97
    [2] => 111
    [3] => 112
    [4] => 113
    [5] => 114
    [6] => 116
)
splash58
  • 26,043
  • 3
  • 22
  • 34