1--TEST--
2Test array_flip() function : usage variations - 'input' argument with different valid values
3--FILE--
4<?php
5/*
6* In 'input' array argument, values are expected to be valid keys i.e. string/integer
7* here testing for all different valid string and integer values
8*/
9
10echo "*** Testing array_flip() : different valid values in 'input' array argument ***\n";
11
12$empty_heredoc = <<<EOT1
13EOT1;
14
15$simple_heredoc = <<<EOT4
16simple
17EOT4;
18
19$multiline_heredoc = <<<EOT7
20multiline heredoc with 123 and
21speci@! ch@r$..checking\nwith\talso
22EOT7;
23
24$input = array(
25  // numeric values
26  'int_value' => 1,
27  'negative_value' => -2,
28  'zero_value' => 0,
29  'octal_value' => 012,
30  'hex_value' => 0x23,
31
32  // single quoted string value
33  'empty_value1' => '',
34  'space_value1' => ' ',
35  'char_value1' => 'a',
36  'string_value1' => 'string1',
37  'numeric_value1' => '123',
38  'special_char_value1' => '!@#$%',
39  'whitespace1_value1' => '\t',
40  'whitespace2_value1' => '\n',
41  'null_char_value1' => '\0',
42
43  // double quoted string value
44  'empty_value2' => "",
45  'space_value2' => " ",
46  'char_value2' => "b",
47  'string_value2' => "string2",
48  'numeric_value2' => "456",
49  'special_char_value2' => "^&*",
50  'whitespace1_value2' => "\t",
51  'whitespace2_value2' => "\n",
52  'null_char_value2' => "\0",
53  'binary_value' => "a".chr(0)."b",
54
55  // heredoc string value
56  'empty_heredoc' => $empty_heredoc,
57  'simple_heredoc' => $simple_heredoc,
58  'multiline_heredoc' => $multiline_heredoc,
59);
60
61var_dump( array_flip($input) );
62
63echo "Done"
64?>
65--EXPECT--
66*** Testing array_flip() : different valid values in 'input' array argument ***
67array(24) {
68  [1]=>
69  string(9) "int_value"
70  [-2]=>
71  string(14) "negative_value"
72  [0]=>
73  string(10) "zero_value"
74  [10]=>
75  string(11) "octal_value"
76  [35]=>
77  string(9) "hex_value"
78  [""]=>
79  string(13) "empty_heredoc"
80  [" "]=>
81  string(12) "space_value2"
82  ["a"]=>
83  string(11) "char_value1"
84  ["string1"]=>
85  string(13) "string_value1"
86  [123]=>
87  string(14) "numeric_value1"
88  ["!@#$%"]=>
89  string(19) "special_char_value1"
90  ["\t"]=>
91  string(18) "whitespace1_value1"
92  ["\n"]=>
93  string(18) "whitespace2_value1"
94  ["\0"]=>
95  string(16) "null_char_value1"
96  ["b"]=>
97  string(11) "char_value2"
98  ["string2"]=>
99  string(13) "string_value2"
100  [456]=>
101  string(14) "numeric_value2"
102  ["^&*"]=>
103  string(19) "special_char_value2"
104  ["	"]=>
105  string(18) "whitespace1_value2"
106  ["
107"]=>
108  string(18) "whitespace2_value2"
109  ["�"]=>
110  string(16) "null_char_value2"
111  ["a�b"]=>
112  string(12) "binary_value"
113  ["simple"]=>
114  string(14) "simple_heredoc"
115  ["multiline heredoc with 123 and
116speci@! ch@r$..checking
117with	also"]=>
118  string(17) "multiline_heredoc"
119}
120Done
121