3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function myIsset($value) { return isset($value); } $array1 = array( // 'str' => 'foo', 'null1' => null, 'null2' => null, 'bool' => true, ); $filtered_array1 = array_filter($array1, 'myIsset'); var_dump($array1, $filtered_array1, array_diff($array1, $filtered_array1)); $array2 = $array1; $array2['bool'] = false; $filtered_array2 = array_filter($array2, 'myIsset'); var_dump($array2, $filtered_array2, array_diff($array2, $filtered_array2));
Output for 4.3.0 - 7.1.0
array(3) { ["null1"]=> NULL ["null2"]=> NULL ["bool"]=> bool(true) } array(1) { ["bool"]=> bool(true) } array(2) { ["null1"]=> NULL ["null2"]=> NULL } array(3) { ["null1"]=> NULL ["null2"]=> NULL ["bool"]=> bool(false) } array(1) { ["bool"]=> bool(false) } array(0) { }