remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_diff_uassoc_variation1.php
blobd57eba54dd5eec0d5ad6ae00092d6fd1647c9bbc
1 <?hh
2 /* Prototype : array array_diff_uassoc(array arr1, array arr2 [, array ...], callback key_comp_func)
3 * Description: Computes the difference of arrays with additional index check which is performed by a
4 * user supplied callback function
5 * Source code: ext/standard/array.c
6 */
8 // define some classes
9 class classWithToString
11 public function __toString() {
12 return "Class A object";
16 class classWithoutToString
20 function key_compare_func($a, $b)
22 if ($a === $b) {
23 return 0;
25 return ($a > $b)? 1:-1;
27 <<__EntryPoint>> function main(): void {
28 echo "*** Testing array_diff_uassoc() : usage variation ***\n";
30 //Initialize variables
31 $array2 = array("a" => "green", "yellow", "red");
33 //get an unset variable
34 $unset_var = 10;
35 unset ($unset_var);
37 //resource variable
38 $fp = fopen(__FILE__, "r");
40 // heredoc string
41 $heredoc = <<<EOT
42 hello world
43 EOT;
45 // add arrays
46 $index_array = array (1, 2, 3);
47 $assoc_array = array ('one' => 1, 'two' => 2);
49 //array of values to iterate over
50 $inputs = array(
52 // int data
53 'int 0' => 0,
54 'int 1' => 1,
55 'int 12345' => 12345,
56 'int -12345' => -2345,
58 // float data
59 'float 10.5' => 10.5,
60 'float -10.5' => -10.5,
61 'float 12.3456789000e10' => 12.3456789000e10,
62 'float -12.3456789000e10' => -12.3456789000e10,
63 'float .5' => .5,
65 // null data
66 'uppercase NULL' => NULL,
67 'lowercase null' => null,
69 // boolean data
70 'lowercase true' => true,
71 'lowercase false' =>false,
72 'uppercase TRUE' =>TRUE,
73 'uppercase FALSE' =>FALSE,
75 // empty data
76 'empty string DQ' => "",
77 'empty string SQ' => '',
79 // string data
80 'string DQ' => "string",
81 'string SQ' => 'string',
82 'mixed case string' => "sTrInG",
83 'heredoc' => $heredoc,
85 // object data
86 'instance of classWithToString' => new classWithToString(),
87 'instance of classWithoutToString' => new classWithoutToString(),
89 // undefined data
90 'undefined var' => @$undefined_var,
92 // unset data
93 'unset var' => @$unset_var,
95 // resource data
96 'resource' => $fp,
99 // loop through each element of the array for arr1
101 foreach($inputs as $key =>$value) {
102 echo "\n--$key--\n";
103 var_dump( array_diff_uassoc($value, $array2, "key_compare_func") );
106 fclose($fp);
107 echo "===DONE===\n";