remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_intersect_uassoc_variation1.php
blobbb42e7276920686f93d7c17a646e777bff0b9d90
1 <?hh
2 /* Prototype : array array_intersect_uassoc(array arr1, array arr2 [, array ...], callback key_compare_func)
3 * Description: Computes the intersection of arrays with additional index check, compares indexes by a callback function
4 * Source code: ext/standard/array.c
5 */
7 // define some classes
8 class classWithToString
10 public function __toString() {
11 return "Class A object";
15 class classWithoutToString
19 //Callback function
20 function key_compare_func($a, $b) {
21 if ($a === $b) {
22 return 0;
24 return ($a > $b) ? 1 : -1;
26 <<__EntryPoint>> function main(): void {
27 echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
29 // Initialise function arguments
30 $array2 = array("a" => "green", "yellow", "red");
31 $array3 = array("a"=>"green", "brown");
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' => -12345,
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
100 foreach($inputs as $key =>$value) {
101 echo "\n--$key--\n";
102 var_dump( array_intersect_uassoc($value, $array2, 'key_compare_func') );
103 var_dump( array_intersect_uassoc($value, $array2, $array3, 'key_compare_func') );
106 fclose($fp);
107 echo "===DONE===\n";