3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function compare($a, $b) { $ret = value_compare_func($a, $b); echo "value_compare_func($a, $b) == $ret\n"; return $ret; } function value_compare_func($a, $b){ if ($a === 'n_3') { return 0; } return 1; } $array1 = array("n_1", "n_2", "n_3", "n_4" ); $array2 = array("green"); $result = array_udiff($array1, $array2, "compare"); print_r($result);
based on td6bE
Output for 7.0.0 - 7.2.0
value_compare_func(n_1, n_2) == 1 value_compare_func(n_3, n_2) == 0 value_compare_func(n_1, n_4) == 1 value_compare_func(n_2, n_4) == 1 value_compare_func(n_3, n_4) == 0 value_compare_func(n_3, green) == 0 value_compare_func(n_3, n_4) == 0 value_compare_func(n_4, n_2) == 1 value_compare_func(n_2, n_1) == 1 Array ( [0] => n_1 [1] => n_2 )
Output for 5.3.19 - 5.6.28
value_compare_func(n_2, n_1) == 1 value_compare_func(n_2, n_3) == 1 value_compare_func(n_4, n_2) == 1 value_compare_func(n_1, n_3) == 1 value_compare_func(n_3, green) == 0 value_compare_func(n_3, n_1) == 0 value_compare_func(n_1, n_2) == 1 value_compare_func(n_2, n_4) == 1 Array ( [1] => n_2 [3] => n_4 )