3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [ 'a' => 'a', 'b' => '', 'c' => null, 'd' => 122, 'e' => 0, 'f' => [ 'g' => 'g', 'h' => 0, 'i' => null, 'j' => '' ] ]; $result = array_filter($array, function ($arr) { if (!is_array($arr)) { return strlen($arr) ; } return array_filter($arr) ; } ) ; $r = array_filter($array) ; var_dump($r);
based on XivSI
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
array(3) { ["a"]=> string(1) "a" ["d"]=> int(122) ["f"]=> array(4) { ["g"]=> string(1) "g" ["h"]=> int(0) ["i"]=> NULL ["j"]=> string(0) "" } }