1--TEST--
2Test array_flip() function : usage variations - 'input' array with different keys
3--FILE--
4<?php
5/*
6* Trying different keys in $input array argument
7*/
8
9echo "*** Testing array_flip() : different keys for 'input' array argument ***\n";
10
11// different heredoc strings
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\nand\talso
22EOT7;
23
24$input = array(
25  // default key
26  'one',  //expected: default key 0, value will be replaced by 'bool_key4'
27
28  // numeric keys
29  1 => 'int_key', // expected: value will be replaced by 'bool_key3'
30  -2 => 'negative_key',
31  012 => 'octal_key',
32  0x34 => 'hex_key',
33
34  // string keys
35  'key' => 'string_key1',
36  "two" => 'string_key2',
37  '' => 'string_key3',
38  "" => 'string_key4',
39  " " => 'string_key5',
40
41  // bool keys
42  true => 'bool_key1',
43  false => 'bool_key2',
44  TRUE => 'bool_key3',
45  FALSE => 'bool_key4',
46
47  // null keys
48  null => 'null_key1',  // expected: value will be replaced by 'null_key2'
49  NULL => 'null_key2',
50
51  // binary key
52  "a".chr(0)."b" => 'binary_key1',
53  b"binary" => 'binary_key2',
54
55  //heredoc keys
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--EXPECTF--
66*** Testing array_flip() : different keys for 'input' array argument ***
67array(13) {
68  ["bool_key4"]=>
69  int(0)
70  ["bool_key3"]=>
71  int(1)
72  ["negative_key"]=>
73  int(-2)
74  ["octal_key"]=>
75  int(10)
76  ["hex_key"]=>
77  int(52)
78  ["string_key1"]=>
79  string(3) "key"
80  ["string_key2"]=>
81  string(3) "two"
82  ["empty_heredoc"]=>
83  string(0) ""
84  ["string_key5"]=>
85  string(1) " "
86  ["binary_key1"]=>
87  string(3) "a%0b"
88  ["binary_key2"]=>
89  string(6) "binary"
90  ["simple_heredoc"]=>
91  string(6) "simple"
92  ["multiline_heredoc"]=>
93  string(6%d) "multiline heredoc with 123 and
94speci@! ch@r$...checking
95and	also"
96}
97Done
98