1--TEST--
2Test array_intersect_uassoc() function : usage variation - Passing class/object methods to callback
3--FILE--
4<?php
5/* Prototype  : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
6 * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
7 * Source code: ext/standard/array.c
8 */
9
10echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
11
12//Initialize variables
13$array1 = array("a" => "green", "c" => "blue", "red");
14$array2 = array("a" => "green", "yellow", "red");
15// define some class with method
16class MyClass
17{
18	static function static_compare_func($a, $b) {
19		return strcasecmp($a, $b);
20	}
21
22	public function class_compare_func($a, $b) {
23		return strcasecmp($a, $b);
24	}
25
26}
27
28echo "\n-- Testing array_intersect_uassoc() function using class with static method as callback --\n";
29var_dump( array_intersect_uassoc($array1, $array2, array('MyClass','static_compare_func')) );
30var_dump( array_intersect_uassoc($array1, $array2, 'MyClass::static_compare_func'));
31
32echo "\n-- Testing array_intersect_uassoc() function using class with regular method as callback --\n";
33$obj = new MyClass();
34var_dump( array_intersect_uassoc($array1, $array2, array($obj,'class_compare_func')) );
35?>
36===DONE===
37--EXPECTF--
38*** Testing array_intersect_uassoc() : usage variation ***
39
40-- Testing array_intersect_uassoc() function using class with static method as callback --
41array(1) {
42  ["a"]=>
43  string(5) "green"
44}
45array(1) {
46  ["a"]=>
47  string(5) "green"
48}
49
50-- Testing array_intersect_uassoc() function using class with regular method as callback --
51array(1) {
52  ["a"]=>
53  string(5) "green"
54}
55===DONE===
56