import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / key_variation2.php
blob6d5664e5745c2b701265b6a6d7982c355a128fae
1 <?php
2 /* Prototype : mixed key(array $array_arg)
3 * Description: Return the key of the element currently pointed to by the internal array pointer
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Pass arrays where keys are different data types as $array_arg to key() to test behaviour
9 */
11 echo "*** Testing key() : usage variations ***\n";
13 //get an unset variable
14 $unset_var = 10;
15 unset ($unset_var);
17 // heredoc string
18 $heredoc = <<<EOT
19 hello world
20 EOT;
22 // unexpected values to be passed as $array_arg
23 $inputs = array(
25 // int data
26 /*1*/ 'int' => array(
27 0 => 'zero',
28 1 => 'one',
29 12345 => 'positive',
30 -2345 => 'negative',
33 // float data
34 /*2*/ 'float' => array(
35 10.5 => 'positive',
36 -10.5 => 'negative',
37 .5 => 'half',
40 /*3*/ 'extreme floats' => array(
41 12.3456789000e6 => 'large',
42 12.3456789000E-10 => 'small',
45 // null data
46 /*4*/ 'null uppercase' => array(
47 NULL => 'null 1',
48 ),
50 /*5*/ 'null lowercase' => array(
51 null => 'null 2',
54 // boolean data
55 /*6*/ 'bool lowercase' => array(
56 true => 'lowert',
57 false => 'lowerf',
60 /*7*/ 'bool uppercase' => array(
61 TRUE => 'uppert',
62 FALSE => 'upperf',
65 // empty data
66 /*8*/ 'empty double quotes' => array(
67 "" => 'emptyd',
70 /*9*/ 'empty single quotes' => array(
71 '' => 'emptys',
74 // string data
75 /*10*/ 'string' => array(
76 "stringd" => 'stringd',
77 'strings' => 'strings',
78 $heredoc => 'stringh',
81 // undefined data
82 /*11*/ 'undefined' => array(
83 @$undefined_var => 'undefined',
86 // unset data
87 /*12*/ 'unset' => array(
88 @$unset_var => 'unset',
92 // loop through each element of $inputs to check the behavior of key()
93 $iterator = 1;
94 foreach($inputs as $key => $input) {
95 echo "\n-- Iteration $iterator : $key data --\n";
96 while (key($input) !== NULL) {
97 var_dump(key($input));
98 next($input);
100 $iterator++;
103 ===DONE===