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
8 * Pass arrays where keys are different data types as $array_arg to key() to test behaviour
11 echo "*** Testing key() : usage variations ***\n";
13 //get an unset variable
22 // unexpected values to be passed as $array_arg
34 /*2*/ 'float' => array(
40 /*3*/ 'extreme floats' => array(
41 12.3456789000e6
=> 'large',
42 12.3456789000E-10 => 'small',
46 /*4*/ 'null uppercase' => array(
50 /*5*/ 'null lowercase' => array(
55 /*6*/ 'bool lowercase' => array(
60 /*7*/ 'bool uppercase' => array(
66 /*8*/ 'empty double quotes' => array(
70 /*9*/ 'empty single quotes' => array(
75 /*10*/ 'string' => array(
76 "stringd" => 'stringd',
77 'strings' => 'strings',
78 $heredoc => 'stringh',
82 /*11*/ 'undefined' => array(
83 @$undefined_var => 'undefined',
87 /*12*/ 'unset' => array(
88 @$unset_var => 'unset',
92 // loop through each element of $inputs to check the behavior of key()
94 foreach($inputs as $key => $input) {
95 echo "\n-- Iteration $iterator : $key data --\n";
96 while (key($input) !== NULL) {
97 var_dump(key($input));