1--TEST--
2Test array_values() function : usage variations - array keys different data types
3--FILE--
4<?php
5/*
6 * Pass arrays where the keys are different data types as $input argument
7 * to array_values() to test behaviour
8 */
9
10echo "*** Testing array_values() : usage variations ***\n";
11
12//get an unset variable
13$unset_var = 10;
14unset ($unset_var);
15
16// heredoc string
17$heredoc = <<<EOT
18hello world
19EOT;
20
21// unexpected values to be passed as $input
22$inputs = array(
23
24       // int data
25/*1*/  'int' => array(
26       0 => 'zero',
27       1 => 'one',
28       12345 => 'positive',
29       -2345 => 'negative',
30       ),
31
32       // null data
33/*4*/ 'null uppercase' => array(
34       NULL => 'null 1',
35       ),
36
37/*5*/  'null lowercase' => array(
38       null => 'null 2',
39       ),
40
41       // boolean data
42/*6*/ 'bool lowercase' => array(
43       true => 'lowert',
44       false => 'lowerf',
45       ),
46
47/*7*/  'bool uppercase' => array(
48       TRUE => 'uppert',
49       FALSE => 'upperf',
50       ),
51
52       // empty data
53/*8*/ 'empty double quotes' => array(
54       "" => 'emptyd',
55       ),
56
57/*9*/  'empty single quotes' => array(
58       '' => 'emptys',
59       ),
60
61       // string data
62/*10*/ 'string' => array(
63       "stringd" => 'stringd',
64       'strings' => 'strings',
65       $heredoc => 'stringh',
66       ),
67
68       // undefined data
69/*11*/ 'undefined' => array(
70       @$undefined_var => 'undefined',
71       ),
72
73       // unset data
74/*12*/ 'unset' => array(
75       @$unset_var => 'unset',
76       ),
77);
78
79// loop through each element of $inputs to check the behavior of array_values()
80$iterator = 1;
81foreach($inputs as $key => $input) {
82  echo "\n-- Iteration $iterator: $key data --\n";
83  var_dump( array_values($input) );
84  $iterator++;
85};
86echo "Done";
87?>
88--EXPECT--
89*** Testing array_values() : usage variations ***
90
91-- Iteration 1: int data --
92array(4) {
93  [0]=>
94  string(4) "zero"
95  [1]=>
96  string(3) "one"
97  [2]=>
98  string(8) "positive"
99  [3]=>
100  string(8) "negative"
101}
102
103-- Iteration 2: null uppercase data --
104array(1) {
105  [0]=>
106  string(6) "null 1"
107}
108
109-- Iteration 3: null lowercase data --
110array(1) {
111  [0]=>
112  string(6) "null 2"
113}
114
115-- Iteration 4: bool lowercase data --
116array(2) {
117  [0]=>
118  string(6) "lowert"
119  [1]=>
120  string(6) "lowerf"
121}
122
123-- Iteration 5: bool uppercase data --
124array(2) {
125  [0]=>
126  string(6) "uppert"
127  [1]=>
128  string(6) "upperf"
129}
130
131-- Iteration 6: empty double quotes data --
132array(1) {
133  [0]=>
134  string(6) "emptyd"
135}
136
137-- Iteration 7: empty single quotes data --
138array(1) {
139  [0]=>
140  string(6) "emptys"
141}
142
143-- Iteration 8: string data --
144array(3) {
145  [0]=>
146  string(7) "stringd"
147  [1]=>
148  string(7) "strings"
149  [2]=>
150  string(7) "stringh"
151}
152
153-- Iteration 9: undefined data --
154array(1) {
155  [0]=>
156  string(9) "undefined"
157}
158
159-- Iteration 10: unset data --
160array(1) {
161  [0]=>
162  string(5) "unset"
163}
164Done
165