sync the repo
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_merge_variation4.php
blobe0164ebd116804119277b09823f221de1ad31ffb
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 = dict['one' => 1, 'two' => 2];
17 // heredoc string
18 $heredoc = <<<EOT
19 hello world
20 EOT;
22 // arrays with keys as different data types to be passed as $input
23 $inputs = dict[
25 // int data
26 /*1*/ 'int' => dict[
27 0 => 'zero',
28 1 => 'one',
29 12345 => 'positive',
30 -2345 => 'negative',
33 // empty data
34 /*2*/ 'empty double quotes' => dict[
35 "" => 'emptyd',
38 /*3*/ 'empty single quotes' => dict[
39 '' => 'emptys',
42 // string data
43 /*4*/ 'string' => dict[
44 "stringd" => 'stringd',
45 'strings' => 'strings',
46 $heredoc => 'stringh',
50 // loop through each element of $inputs to check the behavior of array_merge
51 $iterator = 1;
52 foreach($inputs as $key => $input) {
53 echo "\n-- Iteration $iterator: $key data --\n";
54 var_dump( array_merge($input, $arr) );
55 var_dump( array_merge($arr, $input) );
56 $iterator++;
59 echo "Done";