3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Surprise surprise! When the 2nd array param of array_diff() contains an elemant with value false, // the result will no longer contain null values. class foo { } //hio function myIsset($value) { return isset($value); } $array1 = array( '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 git.master, git.master_jit, rfc.property-hooks
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) { }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
36.22 ms | 402 KiB | 8 Q