fork download
  1. <?php
  2. $result = (new Test)->test();
  3. print_r( $result);
  4.  
  5. class Test {
  6. public $notSet;
  7.  
  8. public function test() {
  9. $old_array = array(
  10. 'a' => 'A',
  11. 'notset' => $notSet,
  12. 'null' => null,
  13. 'false' => false,
  14. 'zeroint' => 0,
  15. 'zerofloat' => 0.0,
  16. );
  17.  
  18. return array_filter($old_array, function($element) {
  19. return ( 0 === $element) ? TRUE : !empty( $element);
  20. });
  21. }
  22. }
Success #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [a] => A
    [zeroint] => 0
)
stderr
PHP Notice:  Undefined variable: notSet in /home/FPOT15/prog.php on line 11
PHP Notice:  Undefined variable: notSet in /home/FPOT15/prog.php on line 11