1--TEST-- 2Test array_intersect_uassoc() function : usage variation - Passing class/object methods to callback 3--FILE-- 4<?php 5echo "*** Testing array_intersect_uassoc() : usage variation ***\n"; 6 7//Initialize variables 8$array1 = array("a" => "green", "c" => "blue", "red"); 9$array2 = array("a" => "green", "yellow", "red"); 10// define some class with method 11class MyClass 12{ 13 static function static_compare_func($a, $b) { 14 return strcasecmp($a, $b); 15 } 16 17 public function class_compare_func($a, $b) { 18 return strcasecmp($a, $b); 19 } 20 21} 22 23echo "\n-- Testing array_intersect_uassoc() function using class with static method as callback --\n"; 24var_dump( array_intersect_uassoc($array1, $array2, array('MyClass','static_compare_func')) ); 25var_dump( array_intersect_uassoc($array1, $array2, 'MyClass::static_compare_func')); 26 27echo "\n-- Testing array_intersect_uassoc() function using class with regular method as callback --\n"; 28$obj = new MyClass(); 29var_dump( array_intersect_uassoc($array1, $array2, array($obj,'class_compare_func')) ); 30?> 31--EXPECT-- 32*** Testing array_intersect_uassoc() : usage variation *** 33 34-- Testing array_intersect_uassoc() function using class with static method as callback -- 35array(1) { 36 ["a"]=> 37 string(5) "green" 38} 39array(1) { 40 ["a"]=> 41 string(5) "green" 42} 43 44-- Testing array_intersect_uassoc() function using class with regular method as callback -- 45array(1) { 46 ["a"]=> 47 string(5) "green" 48} 49