remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_merge_variation4.php
blobb1612e3a578e2894dda70a9092cd19d9ee9276fb
1 <?hh
2 /* Prototype : array array_merge(array $arr1, array $arr2 [, array $...])
3 * Description: Merges elements from passed arrays into one array
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass an array with different data types as keys to test how array_merge
9 * adds it onto an existing array
11 <<__EntryPoint>> function main(): void {
12 echo "*** Testing array_merge() : usage variations ***\n";
14 // Initialise function arguments not being substituted
15 $arr = array ('one' => 1, 'two' => 2);
17 //get an unset variable
18 $unset_var = 10;
19 unset ($unset_var);
21 // heredoc string
22 $heredoc = <<<EOT
23 hello world
24 EOT;
26 // arrays with keys as different data types to be passed as $input
27 $inputs = array(
29 // int data
30 /*1*/ 'int' => array(
31 0 => 'zero',
32 1 => 'one',
33 12345 => 'positive',
34 -2345 => 'negative',
37 // float data
38 /*2*/ 'float' => array(
39 10.5 => 'positive',
40 -10.5 => 'negative',
41 .5 => 'half',
44 /*3*/ 'extreme floats' => array(
45 12.3456789000e10 => 'large',
46 12.3456789000E-10 => 'small',
49 // null data
50 /*4*/ 'null uppercase' => array(
51 NULL => 'null 1',
52 ),
54 /*5*/ 'null lowercase' => array(
55 null => 'null 2',
58 // boolean data
59 /*6*/ 'bool lowercase' => array(
60 true => 'lowert',
61 false => 'lowerf',
64 /*7*/ 'bool uppercase' => array(
65 TRUE => 'uppert',
66 FALSE => 'upperf',
69 // empty data
70 /*8*/ 'empty double quotes' => array(
71 "" => 'emptyd',
74 /*9*/ 'empty single quotes' => array(
75 '' => 'emptys',
78 // string data
79 /*10*/ 'string' => array(
80 "stringd" => 'stringd',
81 'strings' => 'strings',
82 $heredoc => 'stringh',
85 // undefined data
86 /*11*/ 'undefined' => array(
87 @$undefined_var => 'undefined',
90 // unset data
91 /*12*/ 'unset' => array(
92 @$unset_var => 'unset',
96 // loop through each element of $inputs to check the behavior of array_merge
97 $iterator = 1;
98 foreach($inputs as $key => $input) {
99 echo "\n-- Iteration $iterator: $key data --\n";
100 var_dump( array_merge($input, $arr) );
101 var_dump( array_merge($arr, $input) );
102 $iterator++;
105 echo "Done";