1--TEST--
2Test array_udiff() function : usage variation
3--FILE--
4<?php
5/* Prototype  : array array_udiff(array arr1, array arr2 [, array ...], callback data_comp_func)
6 * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments. Elements are compared by user supplied function.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_udiff() : usage variation ***\n";
12
13// Initialise function arguments not being substituted (if any)
14$arr1 = array(1);
15$arr2 = array(1);
16
17echo "\n-- comparison function with an incorrect return value --\n";
18function incorrect_return_value ($val1, $val2) {
19  return array(1);
20}
21var_dump(array_udiff($arr1, $arr2, 'incorrect_return_value'));
22
23echo "\n-- comparison function taking too many parameters --\n";
24function too_many_parameters ($val1, $val2, $val3) {
25  return 0;
26}
27try {
28	var_dump(array_udiff($arr1, $arr2, 'too_many_parameters'));
29} catch (Throwable $e) {
30	echo "Exception: " . $e->getMessage() . "\n";
31}
32
33echo "\n-- comparison function taking too few parameters --\n";
34function too_few_parameters ($val1) {
35  return 0;
36}
37var_dump(array_udiff($arr1, $arr2, 'too_few_parameters'));
38
39?>
40===DONE===
41--EXPECT--
42*** Testing array_udiff() : usage variation ***
43
44-- comparison function with an incorrect return value --
45array(1) {
46  [0]=>
47  int(1)
48}
49
50-- comparison function taking too many parameters --
51Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
52
53-- comparison function taking too few parameters --
54array(0) {
55}
56===DONE===
57