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