fork(1) download
  1. <?php
  2.  
  3. $array = array( 0 => 'aa', 1 => 'bbb', 2 => null, 3 => 'ddd', 4 => null);
  4.  
  5. $arrayf1 = array_filter($array, function($v){if(!empty($v)) return true;});
  6. $arrayf2 = array_filter($array, function($v){return !empty($v);});
  7. $arrayf3 = array_filter($array);
  8.  
  9. print_r($array);
  10. print_r($arrayf1);
  11. print_r($arrayf2);
  12. print_r($arrayf3);
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Array
(
    [0] => aa
    [1] => bbb
    [2] => 
    [3] => ddd
    [4] => 
)
Array
(
    [0] => aa
    [1] => bbb
    [3] => ddd
)
Array
(
    [0] => aa
    [1] => bbb
    [3] => ddd
)
Array
(
    [0] => aa
    [1] => bbb
    [3] => ddd
)