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); $array2 = $array1; $array2['bool'] = false; $filtered_array2 = array_filter($array2, 'myIsset'); var_dump($array2, $filtered_array2);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { ["str"]=> string(3) "foo" ["null1"]=> NULL ["null2"]=> NULL ["bool"]=> bool(true) } array(2) { ["str"]=> string(3) "foo" ["bool"]=> bool(true) } array(4) { ["str"]=> string(3) "foo" ["null1"]=> NULL ["null2"]=> NULL ["bool"]=> bool(false) } array(2) { ["str"]=> string(3) "foo" ["bool"]=> bool(false) }