1--TEST--
2Test array_flip() function : basic functionality
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
10echo "*** Testing array_flip() : basic functionality ***\n";
11
12// array with default keys - numeric values
13$input = array(1, 2);
14var_dump( array_flip($input) );
15
16// array with default keys - string values
17$input = array('value1', "value2");
18var_dump( array_flip($input) );
19
20// associative arrays - key as string
21$input = array('key1' => 1, "key2" => 2);
22var_dump( array_flip($input) );
23
24// associative arrays - key as numeric
25$input = array(1 => 'one', 2 => "two");
26var_dump( array_flip($input) );
27
28// combination of associative and non-associative array
29$input = array(1 => 'one','two', 3 => 'three', 4, "five" => 5);
30var_dump( array_flip($input) );
31echo "Done"
32?>
33--EXPECT--
34*** Testing array_flip() : basic functionality ***
35array(2) {
36  [1]=>
37  int(0)
38  [2]=>
39  int(1)
40}
41array(2) {
42  ["value1"]=>
43  int(0)
44  ["value2"]=>
45  int(1)
46}
47array(2) {
48  [1]=>
49  string(4) "key1"
50  [2]=>
51  string(4) "key2"
52}
53array(2) {
54  ["one"]=>
55  int(1)
56  ["two"]=>
57  int(2)
58}
59array(5) {
60  ["one"]=>
61  int(1)
62  ["two"]=>
63  int(2)
64  ["three"]=>
65  int(3)
66  [4]=>
67  int(4)
68  [5]=>
69  string(4) "five"
70}
71Done
72