102dd0140SRaghubansh Kumar--TEST--
202dd0140SRaghubansh KumarTest key(), current(), next() & reset() functions
302dd0140SRaghubansh Kumar--FILE--
402dd0140SRaghubansh Kumar<?php
5782352c5SPeter Kokot/* Prototype & Usage:
602dd0140SRaghubansh Kumar   mixed key ( array &$array ) -> returns the index element of the current array position
702dd0140SRaghubansh Kumar   mixed current ( array &$array ) -> returns the current element in the array
802dd0140SRaghubansh Kumar   mixed next ( array &$array ) -> similar to current() but advances the internal pointer to next element
902dd0140SRaghubansh Kumar   mixed reset ( array &$array ) -> Reset the internal pointer to first element
1002dd0140SRaghubansh Kumar*/
1102dd0140SRaghubansh Kumar
1202dd0140SRaghubansh Kumar$basic_arrays = array (
1302dd0140SRaghubansh Kumar  array(0),  // array with element as 0
1402dd0140SRaghubansh Kumar  array(1),  // array with single element
1502dd0140SRaghubansh Kumar  array(1,2, 3, -1, -2, -3),               // array of integers
1602dd0140SRaghubansh Kumar  array(1.1, 2.2, 3.3, -1.1, -2.2, -3.3),  // array of floats
1702dd0140SRaghubansh Kumar  array('a', 'b', 'c', "ab", "ac", "ad"),  // string array
1802dd0140SRaghubansh Kumar  array("a" => "apple", "b" => "book", "c" => "cook"),  // associative array
1902dd0140SRaghubansh Kumar  array('d' => 'drink', 'p' => 'port', 's' => 'set'),   // another associative array
2002dd0140SRaghubansh Kumar  array(1 => 'One', 2 => 'two', 3 => "three")           // associative array with key as integers
2102dd0140SRaghubansh Kumar);
22782352c5SPeter Kokot
2302dd0140SRaghubansh Kumar$varient_arrays = array (
2402dd0140SRaghubansh Kumar   array(),    // empty array
2502dd0140SRaghubansh Kumar   array(""),  // array with null string
26782352c5SPeter Kokot   array(NULL),// array with NULL
2702dd0140SRaghubansh Kumar   array(null),// array with null
2802dd0140SRaghubansh Kumar   array(NULL, true, null, "", 1), // mixed array
29782352c5SPeter Kokot   array(-1.5 => "test", -2 => "rest", 2.5 => "two",
3002dd0140SRaghubansh Kumar         "" => "string", 0 => "zero", "" => "" ) // mixed array
31782352c5SPeter Kokot);
3202dd0140SRaghubansh Kumar
3302dd0140SRaghubansh Kumarecho "*** Testing basic operations ***\n";
3402dd0140SRaghubansh Kumar$loop_count = 1;
3502dd0140SRaghubansh Kumarforeach ($basic_arrays as $sub_array )  {
3602dd0140SRaghubansh Kumar  echo "-- Iteration $loop_count --\n";
3702dd0140SRaghubansh Kumar  $loop_count++;
3802dd0140SRaghubansh Kumar  $c = count ($sub_array);
3902dd0140SRaghubansh Kumar  $c++; // increment by one to create the situation of accessing beyond array size
4002dd0140SRaghubansh Kumar  while ( $c ) {
4102dd0140SRaghubansh Kumar    var_dump( current($sub_array)); // current element
4202dd0140SRaghubansh Kumar    var_dump( key($sub_array) );    // key of the current element
4302dd0140SRaghubansh Kumar    var_dump( next($sub_array) );   // move to next element
4402dd0140SRaghubansh Kumar    $c --;
4502dd0140SRaghubansh Kumar  }
4602dd0140SRaghubansh Kumar  var_dump( reset($sub_array) );    // reset the internal pointer to first element
4702dd0140SRaghubansh Kumar  var_dump( key($sub_array) );      // access the array after reset
4802dd0140SRaghubansh Kumar  var_dump( $sub_array );           // dump the array to see that its intact
4902dd0140SRaghubansh Kumar
5002dd0140SRaghubansh Kumar  echo "\n";
5102dd0140SRaghubansh Kumar}
5202dd0140SRaghubansh Kumar
5302dd0140SRaghubansh Kumarecho "\n*** Testing possible variations ***\n";
5402dd0140SRaghubansh Kumar$loop_count = 1;
5502dd0140SRaghubansh Kumarforeach ($varient_arrays as $sub_array )  {
5602dd0140SRaghubansh Kumar  echo "-- Iteration $loop_count --\n";
5702dd0140SRaghubansh Kumar  $loop_count++;
5802dd0140SRaghubansh Kumar  $c = count ($sub_array);
5902dd0140SRaghubansh Kumar  $c++; // increment by one to create the situation of accessing beyond array size
6002dd0140SRaghubansh Kumar  while ( $c ) {
6102dd0140SRaghubansh Kumar    var_dump( current($sub_array)); // current element
6202dd0140SRaghubansh Kumar    var_dump( key($sub_array) );    // key of the current element
6302dd0140SRaghubansh Kumar    var_dump( next($sub_array) );   // move to next element
6402dd0140SRaghubansh Kumar    $c --;
6502dd0140SRaghubansh Kumar  }
6602dd0140SRaghubansh Kumar  var_dump( reset($sub_array) );    // reset the internal pointer to first element
6702dd0140SRaghubansh Kumar  var_dump( key($sub_array) );      // access the array after reset
6802dd0140SRaghubansh Kumar  var_dump( $sub_array );           // dump the array to see that its intact
6902dd0140SRaghubansh Kumar  echo "\n";
7002dd0140SRaghubansh Kumar}
7102dd0140SRaghubansh Kumar
72782352c5SPeter Kokot/*test these functions on array which is already unset */
7302dd0140SRaghubansh Kumarecho "\n-- Testing variation: when array is unset --\n";
7402dd0140SRaghubansh Kumar$unset_array = array (1);
7502dd0140SRaghubansh Kumarunset($unset_array);
7602dd0140SRaghubansh Kumar
7702dd0140SRaghubansh Kumarvar_dump( current($unset_array) );
7802dd0140SRaghubansh Kumarvar_dump( key($unset_array) );
7902dd0140SRaghubansh Kumarvar_dump( next($unset_array) );
8002dd0140SRaghubansh Kumarvar_dump( reset($unset_array) );
8102dd0140SRaghubansh Kumar
8202dd0140SRaghubansh Kumar
8302dd0140SRaghubansh Kumarecho "\n*** Testing error conditions ***\n";
8402dd0140SRaghubansh Kumar//Zero argument, expected 1 argument
8502dd0140SRaghubansh Kumarvar_dump( key() );
8602dd0140SRaghubansh Kumarvar_dump( current() );
8702dd0140SRaghubansh Kumarvar_dump( reset() );
8802dd0140SRaghubansh Kumarvar_dump( next() );
8902dd0140SRaghubansh Kumar
9002dd0140SRaghubansh Kumar// args more than expected, expected 1 argument
9102dd0140SRaghubansh Kumar$temp_array = array(1);
9202dd0140SRaghubansh Kumarvar_dump( key($temp_array, $temp_array) );
9302dd0140SRaghubansh Kumarvar_dump( current($temp_array, $temp_array) );
9402dd0140SRaghubansh Kumarvar_dump( reset($temp_array, $temp_array) );
9502dd0140SRaghubansh Kumarvar_dump( next($temp_array, $temp_array) );
9602dd0140SRaghubansh Kumar
97782352c5SPeter Kokot// invalid args type, valid argument: array
9802dd0140SRaghubansh Kumar$int_var = 1;
9902dd0140SRaghubansh Kumar$float_var = 1.5;
10002dd0140SRaghubansh Kumar$string = "string";
10102dd0140SRaghubansh Kumarvar_dump( key($int_var) );
10202dd0140SRaghubansh Kumarvar_dump( key($float_var) );
10302dd0140SRaghubansh Kumarvar_dump( key($string) );
10402dd0140SRaghubansh Kumar
10502dd0140SRaghubansh Kumarvar_dump( current($int_var) );
10602dd0140SRaghubansh Kumarvar_dump( current($float_var) );
10702dd0140SRaghubansh Kumarvar_dump( current($string) );
10802dd0140SRaghubansh Kumar
10902dd0140SRaghubansh Kumarvar_dump( next($int_var) );
11002dd0140SRaghubansh Kumarvar_dump( next($float_var) );
11102dd0140SRaghubansh Kumarvar_dump( next($string) );
11202dd0140SRaghubansh Kumar
11302dd0140SRaghubansh Kumarvar_dump( reset($int_var) );
11402dd0140SRaghubansh Kumarvar_dump( reset($float_var) );
11502dd0140SRaghubansh Kumarvar_dump( reset($string) );
11602dd0140SRaghubansh Kumar
11702dd0140SRaghubansh Kumarecho "Done\n";
11802dd0140SRaghubansh Kumar?>
119782352c5SPeter Kokot--EXPECTF--
12002dd0140SRaghubansh Kumar*** Testing basic operations ***
12102dd0140SRaghubansh Kumar-- Iteration 1 --
12202dd0140SRaghubansh Kumarint(0)
12302dd0140SRaghubansh Kumarint(0)
12402dd0140SRaghubansh Kumarbool(false)
12502dd0140SRaghubansh Kumarbool(false)
12602dd0140SRaghubansh KumarNULL
12702dd0140SRaghubansh Kumarbool(false)
12802dd0140SRaghubansh Kumarint(0)
12902dd0140SRaghubansh Kumarint(0)
13002dd0140SRaghubansh Kumararray(1) {
13102dd0140SRaghubansh Kumar  [0]=>
13202dd0140SRaghubansh Kumar  int(0)
13302dd0140SRaghubansh Kumar}
13402dd0140SRaghubansh Kumar
13502dd0140SRaghubansh Kumar-- Iteration 2 --
13602dd0140SRaghubansh Kumarint(1)
13702dd0140SRaghubansh Kumarint(0)
13802dd0140SRaghubansh Kumarbool(false)
13902dd0140SRaghubansh Kumarbool(false)
14002dd0140SRaghubansh KumarNULL
14102dd0140SRaghubansh Kumarbool(false)
14202dd0140SRaghubansh Kumarint(1)
14302dd0140SRaghubansh Kumarint(0)
14402dd0140SRaghubansh Kumararray(1) {
14502dd0140SRaghubansh Kumar  [0]=>
14602dd0140SRaghubansh Kumar  int(1)
14702dd0140SRaghubansh Kumar}
14802dd0140SRaghubansh Kumar
14902dd0140SRaghubansh Kumar-- Iteration 3 --
15002dd0140SRaghubansh Kumarint(1)
15102dd0140SRaghubansh Kumarint(0)
15202dd0140SRaghubansh Kumarint(2)
15302dd0140SRaghubansh Kumarint(2)
15402dd0140SRaghubansh Kumarint(1)
15502dd0140SRaghubansh Kumarint(3)
15602dd0140SRaghubansh Kumarint(3)
15702dd0140SRaghubansh Kumarint(2)
15802dd0140SRaghubansh Kumarint(-1)
15902dd0140SRaghubansh Kumarint(-1)
16002dd0140SRaghubansh Kumarint(3)
16102dd0140SRaghubansh Kumarint(-2)
16202dd0140SRaghubansh Kumarint(-2)
16302dd0140SRaghubansh Kumarint(4)
16402dd0140SRaghubansh Kumarint(-3)
16502dd0140SRaghubansh Kumarint(-3)
16602dd0140SRaghubansh Kumarint(5)
16702dd0140SRaghubansh Kumarbool(false)
16802dd0140SRaghubansh Kumarbool(false)
16902dd0140SRaghubansh KumarNULL
17002dd0140SRaghubansh Kumarbool(false)
17102dd0140SRaghubansh Kumarint(1)
17202dd0140SRaghubansh Kumarint(0)
17302dd0140SRaghubansh Kumararray(6) {
17402dd0140SRaghubansh Kumar  [0]=>
17502dd0140SRaghubansh Kumar  int(1)
17602dd0140SRaghubansh Kumar  [1]=>
17702dd0140SRaghubansh Kumar  int(2)
17802dd0140SRaghubansh Kumar  [2]=>
17902dd0140SRaghubansh Kumar  int(3)
18002dd0140SRaghubansh Kumar  [3]=>
18102dd0140SRaghubansh Kumar  int(-1)
18202dd0140SRaghubansh Kumar  [4]=>
18302dd0140SRaghubansh Kumar  int(-2)
18402dd0140SRaghubansh Kumar  [5]=>
18502dd0140SRaghubansh Kumar  int(-3)
18602dd0140SRaghubansh Kumar}
18702dd0140SRaghubansh Kumar
18802dd0140SRaghubansh Kumar-- Iteration 4 --
18902dd0140SRaghubansh Kumarfloat(1.1)
19002dd0140SRaghubansh Kumarint(0)
19102dd0140SRaghubansh Kumarfloat(2.2)
19202dd0140SRaghubansh Kumarfloat(2.2)
19302dd0140SRaghubansh Kumarint(1)
19402dd0140SRaghubansh Kumarfloat(3.3)
19502dd0140SRaghubansh Kumarfloat(3.3)
19602dd0140SRaghubansh Kumarint(2)
19702dd0140SRaghubansh Kumarfloat(-1.1)
19802dd0140SRaghubansh Kumarfloat(-1.1)
19902dd0140SRaghubansh Kumarint(3)
20002dd0140SRaghubansh Kumarfloat(-2.2)
20102dd0140SRaghubansh Kumarfloat(-2.2)
20202dd0140SRaghubansh Kumarint(4)
20302dd0140SRaghubansh Kumarfloat(-3.3)
20402dd0140SRaghubansh Kumarfloat(-3.3)
20502dd0140SRaghubansh Kumarint(5)
20602dd0140SRaghubansh Kumarbool(false)
20702dd0140SRaghubansh Kumarbool(false)
20802dd0140SRaghubansh KumarNULL
20902dd0140SRaghubansh Kumarbool(false)
21002dd0140SRaghubansh Kumarfloat(1.1)
21102dd0140SRaghubansh Kumarint(0)
21202dd0140SRaghubansh Kumararray(6) {
21302dd0140SRaghubansh Kumar  [0]=>
21402dd0140SRaghubansh Kumar  float(1.1)
21502dd0140SRaghubansh Kumar  [1]=>
21602dd0140SRaghubansh Kumar  float(2.2)
21702dd0140SRaghubansh Kumar  [2]=>
21802dd0140SRaghubansh Kumar  float(3.3)
21902dd0140SRaghubansh Kumar  [3]=>
22002dd0140SRaghubansh Kumar  float(-1.1)
22102dd0140SRaghubansh Kumar  [4]=>
22202dd0140SRaghubansh Kumar  float(-2.2)
22302dd0140SRaghubansh Kumar  [5]=>
22402dd0140SRaghubansh Kumar  float(-3.3)
22502dd0140SRaghubansh Kumar}
22602dd0140SRaghubansh Kumar
22702dd0140SRaghubansh Kumar-- Iteration 5 --
22802dd0140SRaghubansh Kumarstring(1) "a"
22902dd0140SRaghubansh Kumarint(0)
23002dd0140SRaghubansh Kumarstring(1) "b"
23102dd0140SRaghubansh Kumarstring(1) "b"
23202dd0140SRaghubansh Kumarint(1)
23302dd0140SRaghubansh Kumarstring(1) "c"
23402dd0140SRaghubansh Kumarstring(1) "c"
23502dd0140SRaghubansh Kumarint(2)
23602dd0140SRaghubansh Kumarstring(2) "ab"
23702dd0140SRaghubansh Kumarstring(2) "ab"
23802dd0140SRaghubansh Kumarint(3)
23902dd0140SRaghubansh Kumarstring(2) "ac"
24002dd0140SRaghubansh Kumarstring(2) "ac"
24102dd0140SRaghubansh Kumarint(4)
24202dd0140SRaghubansh Kumarstring(2) "ad"
24302dd0140SRaghubansh Kumarstring(2) "ad"
24402dd0140SRaghubansh Kumarint(5)
24502dd0140SRaghubansh Kumarbool(false)
24602dd0140SRaghubansh Kumarbool(false)
24702dd0140SRaghubansh KumarNULL
24802dd0140SRaghubansh Kumarbool(false)
24902dd0140SRaghubansh Kumarstring(1) "a"
25002dd0140SRaghubansh Kumarint(0)
25102dd0140SRaghubansh Kumararray(6) {
25202dd0140SRaghubansh Kumar  [0]=>
25302dd0140SRaghubansh Kumar  string(1) "a"
25402dd0140SRaghubansh Kumar  [1]=>
25502dd0140SRaghubansh Kumar  string(1) "b"
25602dd0140SRaghubansh Kumar  [2]=>
25702dd0140SRaghubansh Kumar  string(1) "c"
25802dd0140SRaghubansh Kumar  [3]=>
25902dd0140SRaghubansh Kumar  string(2) "ab"
26002dd0140SRaghubansh Kumar  [4]=>
26102dd0140SRaghubansh Kumar  string(2) "ac"
26202dd0140SRaghubansh Kumar  [5]=>
26302dd0140SRaghubansh Kumar  string(2) "ad"
26402dd0140SRaghubansh Kumar}
26502dd0140SRaghubansh Kumar
26602dd0140SRaghubansh Kumar-- Iteration 6 --
26702dd0140SRaghubansh Kumarstring(5) "apple"
26802dd0140SRaghubansh Kumarstring(1) "a"
26902dd0140SRaghubansh Kumarstring(4) "book"
27002dd0140SRaghubansh Kumarstring(4) "book"
27102dd0140SRaghubansh Kumarstring(1) "b"
27202dd0140SRaghubansh Kumarstring(4) "cook"
27302dd0140SRaghubansh Kumarstring(4) "cook"
27402dd0140SRaghubansh Kumarstring(1) "c"
27502dd0140SRaghubansh Kumarbool(false)
27602dd0140SRaghubansh Kumarbool(false)
27702dd0140SRaghubansh KumarNULL
27802dd0140SRaghubansh Kumarbool(false)
27902dd0140SRaghubansh Kumarstring(5) "apple"
28002dd0140SRaghubansh Kumarstring(1) "a"
28102dd0140SRaghubansh Kumararray(3) {
28202dd0140SRaghubansh Kumar  ["a"]=>
28302dd0140SRaghubansh Kumar  string(5) "apple"
28402dd0140SRaghubansh Kumar  ["b"]=>
28502dd0140SRaghubansh Kumar  string(4) "book"
28602dd0140SRaghubansh Kumar  ["c"]=>
28702dd0140SRaghubansh Kumar  string(4) "cook"
28802dd0140SRaghubansh Kumar}
28902dd0140SRaghubansh Kumar
29002dd0140SRaghubansh Kumar-- Iteration 7 --
29102dd0140SRaghubansh Kumarstring(5) "drink"
29202dd0140SRaghubansh Kumarstring(1) "d"
29302dd0140SRaghubansh Kumarstring(4) "port"
29402dd0140SRaghubansh Kumarstring(4) "port"
29502dd0140SRaghubansh Kumarstring(1) "p"
29602dd0140SRaghubansh Kumarstring(3) "set"
29702dd0140SRaghubansh Kumarstring(3) "set"
29802dd0140SRaghubansh Kumarstring(1) "s"
29902dd0140SRaghubansh Kumarbool(false)
30002dd0140SRaghubansh Kumarbool(false)
30102dd0140SRaghubansh KumarNULL
30202dd0140SRaghubansh Kumarbool(false)
30302dd0140SRaghubansh Kumarstring(5) "drink"
30402dd0140SRaghubansh Kumarstring(1) "d"
30502dd0140SRaghubansh Kumararray(3) {
30602dd0140SRaghubansh Kumar  ["d"]=>
30702dd0140SRaghubansh Kumar  string(5) "drink"
30802dd0140SRaghubansh Kumar  ["p"]=>
30902dd0140SRaghubansh Kumar  string(4) "port"
31002dd0140SRaghubansh Kumar  ["s"]=>
31102dd0140SRaghubansh Kumar  string(3) "set"
31202dd0140SRaghubansh Kumar}
31302dd0140SRaghubansh Kumar
31402dd0140SRaghubansh Kumar-- Iteration 8 --
31502dd0140SRaghubansh Kumarstring(3) "One"
31602dd0140SRaghubansh Kumarint(1)
31702dd0140SRaghubansh Kumarstring(3) "two"
31802dd0140SRaghubansh Kumarstring(3) "two"
31902dd0140SRaghubansh Kumarint(2)
32002dd0140SRaghubansh Kumarstring(5) "three"
32102dd0140SRaghubansh Kumarstring(5) "three"
32202dd0140SRaghubansh Kumarint(3)
32302dd0140SRaghubansh Kumarbool(false)
32402dd0140SRaghubansh Kumarbool(false)
32502dd0140SRaghubansh KumarNULL
32602dd0140SRaghubansh Kumarbool(false)
32702dd0140SRaghubansh Kumarstring(3) "One"
32802dd0140SRaghubansh Kumarint(1)
32902dd0140SRaghubansh Kumararray(3) {
33002dd0140SRaghubansh Kumar  [1]=>
33102dd0140SRaghubansh Kumar  string(3) "One"
33202dd0140SRaghubansh Kumar  [2]=>
33302dd0140SRaghubansh Kumar  string(3) "two"
33402dd0140SRaghubansh Kumar  [3]=>
33502dd0140SRaghubansh Kumar  string(5) "three"
33602dd0140SRaghubansh Kumar}
33702dd0140SRaghubansh Kumar
33802dd0140SRaghubansh Kumar
33902dd0140SRaghubansh Kumar*** Testing possible variations ***
34002dd0140SRaghubansh Kumar-- Iteration 1 --
34102dd0140SRaghubansh Kumarbool(false)
34202dd0140SRaghubansh KumarNULL
34302dd0140SRaghubansh Kumarbool(false)
34402dd0140SRaghubansh Kumarbool(false)
34502dd0140SRaghubansh KumarNULL
34602dd0140SRaghubansh Kumararray(0) {
34702dd0140SRaghubansh Kumar}
34802dd0140SRaghubansh Kumar
34902dd0140SRaghubansh Kumar-- Iteration 2 --
35002dd0140SRaghubansh Kumarstring(0) ""
35102dd0140SRaghubansh Kumarint(0)
35202dd0140SRaghubansh Kumarbool(false)
35302dd0140SRaghubansh Kumarbool(false)
35402dd0140SRaghubansh KumarNULL
35502dd0140SRaghubansh Kumarbool(false)
35602dd0140SRaghubansh Kumarstring(0) ""
35702dd0140SRaghubansh Kumarint(0)
35802dd0140SRaghubansh Kumararray(1) {
35902dd0140SRaghubansh Kumar  [0]=>
36002dd0140SRaghubansh Kumar  string(0) ""
36102dd0140SRaghubansh Kumar}
36202dd0140SRaghubansh Kumar
36302dd0140SRaghubansh Kumar-- Iteration 3 --
36402dd0140SRaghubansh KumarNULL
36502dd0140SRaghubansh Kumarint(0)
36602dd0140SRaghubansh Kumarbool(false)
36702dd0140SRaghubansh Kumarbool(false)
36802dd0140SRaghubansh KumarNULL
36902dd0140SRaghubansh Kumarbool(false)
37002dd0140SRaghubansh KumarNULL
37102dd0140SRaghubansh Kumarint(0)
37202dd0140SRaghubansh Kumararray(1) {
37302dd0140SRaghubansh Kumar  [0]=>
37402dd0140SRaghubansh Kumar  NULL
37502dd0140SRaghubansh Kumar}
37602dd0140SRaghubansh Kumar
37702dd0140SRaghubansh Kumar-- Iteration 4 --
37802dd0140SRaghubansh KumarNULL
37902dd0140SRaghubansh Kumarint(0)
38002dd0140SRaghubansh Kumarbool(false)
38102dd0140SRaghubansh Kumarbool(false)
38202dd0140SRaghubansh KumarNULL
38302dd0140SRaghubansh Kumarbool(false)
38402dd0140SRaghubansh KumarNULL
38502dd0140SRaghubansh Kumarint(0)
38602dd0140SRaghubansh Kumararray(1) {
38702dd0140SRaghubansh Kumar  [0]=>
38802dd0140SRaghubansh Kumar  NULL
38902dd0140SRaghubansh Kumar}
39002dd0140SRaghubansh Kumar
39102dd0140SRaghubansh Kumar-- Iteration 5 --
39202dd0140SRaghubansh KumarNULL
39302dd0140SRaghubansh Kumarint(0)
39402dd0140SRaghubansh Kumarbool(true)
39502dd0140SRaghubansh Kumarbool(true)
39602dd0140SRaghubansh Kumarint(1)
39702dd0140SRaghubansh KumarNULL
39802dd0140SRaghubansh KumarNULL
39902dd0140SRaghubansh Kumarint(2)
40002dd0140SRaghubansh Kumarstring(0) ""
40102dd0140SRaghubansh Kumarstring(0) ""
40202dd0140SRaghubansh Kumarint(3)
40302dd0140SRaghubansh Kumarint(1)
40402dd0140SRaghubansh Kumarint(1)
40502dd0140SRaghubansh Kumarint(4)
40602dd0140SRaghubansh Kumarbool(false)
40702dd0140SRaghubansh Kumarbool(false)
40802dd0140SRaghubansh KumarNULL
40902dd0140SRaghubansh Kumarbool(false)
41002dd0140SRaghubansh KumarNULL
41102dd0140SRaghubansh Kumarint(0)
41202dd0140SRaghubansh Kumararray(5) {
41302dd0140SRaghubansh Kumar  [0]=>
41402dd0140SRaghubansh Kumar  NULL
41502dd0140SRaghubansh Kumar  [1]=>
41602dd0140SRaghubansh Kumar  bool(true)
41702dd0140SRaghubansh Kumar  [2]=>
41802dd0140SRaghubansh Kumar  NULL
41902dd0140SRaghubansh Kumar  [3]=>
42002dd0140SRaghubansh Kumar  string(0) ""
42102dd0140SRaghubansh Kumar  [4]=>
42202dd0140SRaghubansh Kumar  int(1)
42302dd0140SRaghubansh Kumar}
42402dd0140SRaghubansh Kumar
42502dd0140SRaghubansh Kumar-- Iteration 6 --
42602dd0140SRaghubansh Kumarstring(4) "test"
42702dd0140SRaghubansh Kumarint(-1)
42802dd0140SRaghubansh Kumarstring(4) "rest"
42902dd0140SRaghubansh Kumarstring(4) "rest"
43002dd0140SRaghubansh Kumarint(-2)
43102dd0140SRaghubansh Kumarstring(3) "two"
43202dd0140SRaghubansh Kumarstring(3) "two"
43302dd0140SRaghubansh Kumarint(2)
43402dd0140SRaghubansh Kumarstring(0) ""
43502dd0140SRaghubansh Kumarstring(0) ""
43602dd0140SRaghubansh Kumarstring(0) ""
43702dd0140SRaghubansh Kumarstring(4) "zero"
43802dd0140SRaghubansh Kumarstring(4) "zero"
43902dd0140SRaghubansh Kumarint(0)
44002dd0140SRaghubansh Kumarbool(false)
44102dd0140SRaghubansh Kumarbool(false)
44202dd0140SRaghubansh KumarNULL
44302dd0140SRaghubansh Kumarbool(false)
44402dd0140SRaghubansh Kumarstring(4) "test"
44502dd0140SRaghubansh Kumarint(-1)
44602dd0140SRaghubansh Kumararray(5) {
44702dd0140SRaghubansh Kumar  [-1]=>
44802dd0140SRaghubansh Kumar  string(4) "test"
44902dd0140SRaghubansh Kumar  [-2]=>
45002dd0140SRaghubansh Kumar  string(4) "rest"
45102dd0140SRaghubansh Kumar  [2]=>
45202dd0140SRaghubansh Kumar  string(3) "two"
45302dd0140SRaghubansh Kumar  [""]=>
45402dd0140SRaghubansh Kumar  string(0) ""
45502dd0140SRaghubansh Kumar  [0]=>
45602dd0140SRaghubansh Kumar  string(4) "zero"
45702dd0140SRaghubansh Kumar}
45802dd0140SRaghubansh Kumar
45902dd0140SRaghubansh Kumar
46002dd0140SRaghubansh Kumar-- Testing variation: when array is unset --
46102dd0140SRaghubansh Kumar
462745504eaSDmitry StogovNotice: Undefined variable: unset_array in %s on line %d
463745504eaSDmitry Stogov
464a541bb80SJani TaskinenWarning: current() expects parameter 1 to be array, null given in %s on line %d
465a541bb80SJani TaskinenNULL
46602dd0140SRaghubansh Kumar
467745504eaSDmitry StogovNotice: Undefined variable: unset_array in %s on line %d
468745504eaSDmitry Stogov
469a541bb80SJani TaskinenWarning: key() expects parameter 1 to be array, null given in %s on line %d
470a541bb80SJani TaskinenNULL
47102dd0140SRaghubansh Kumar
472a541bb80SJani TaskinenWarning: next() expects parameter 1 to be array, null given in %s on line %d
473a541bb80SJani TaskinenNULL
47402dd0140SRaghubansh Kumar
475a541bb80SJani TaskinenWarning: reset() expects parameter 1 to be array, null given in %s on line %d
476a541bb80SJani TaskinenNULL
47702dd0140SRaghubansh Kumar
47802dd0140SRaghubansh Kumar*** Testing error conditions ***
47902dd0140SRaghubansh Kumar
480a541bb80SJani TaskinenWarning: key() expects exactly 1 parameter, 0 given in %s on line %d
48102dd0140SRaghubansh KumarNULL
48202dd0140SRaghubansh Kumar
483a541bb80SJani TaskinenWarning: current() expects exactly 1 parameter, 0 given in %s on line %d
48402dd0140SRaghubansh KumarNULL
48502dd0140SRaghubansh Kumar
486a541bb80SJani TaskinenWarning: reset() expects exactly 1 parameter, 0 given in %s on line %d
48702dd0140SRaghubansh KumarNULL
48802dd0140SRaghubansh Kumar
489a541bb80SJani TaskinenWarning: next() expects exactly 1 parameter, 0 given in %s on line %d
49002dd0140SRaghubansh KumarNULL
49102dd0140SRaghubansh Kumar
492a541bb80SJani TaskinenWarning: key() expects exactly 1 parameter, 2 given in %s on line %d
49302dd0140SRaghubansh KumarNULL
49402dd0140SRaghubansh Kumar
495a541bb80SJani TaskinenWarning: current() expects exactly 1 parameter, 2 given in %s on line %d
49602dd0140SRaghubansh KumarNULL
49702dd0140SRaghubansh Kumar
498a541bb80SJani TaskinenWarning: reset() expects exactly 1 parameter, 2 given in %s on line %d
49902dd0140SRaghubansh KumarNULL
50002dd0140SRaghubansh Kumar
501a541bb80SJani TaskinenWarning: next() expects exactly 1 parameter, 2 given in %s on line %d
50202dd0140SRaghubansh KumarNULL
50302dd0140SRaghubansh Kumar
504ce1d69a1SGabriel CarusoWarning: key() expects parameter 1 to be array, int given in %s on line %d
505a541bb80SJani TaskinenNULL
50602dd0140SRaghubansh Kumar
507e5eb9530SAndrea FauldsWarning: key() expects parameter 1 to be array, float given in %s on line %d
508a541bb80SJani TaskinenNULL
50902dd0140SRaghubansh Kumar
510a541bb80SJani TaskinenWarning: key() expects parameter 1 to be array, string given in %s on line %d
511a541bb80SJani TaskinenNULL
51202dd0140SRaghubansh Kumar
513ce1d69a1SGabriel CarusoWarning: current() expects parameter 1 to be array, int given in %s on line %d
514a541bb80SJani TaskinenNULL
51502dd0140SRaghubansh Kumar
516e5eb9530SAndrea FauldsWarning: current() expects parameter 1 to be array, float given in %s on line %d
517a541bb80SJani TaskinenNULL
51802dd0140SRaghubansh Kumar
519a541bb80SJani TaskinenWarning: current() expects parameter 1 to be array, string given in %s on line %d
520a541bb80SJani TaskinenNULL
52102dd0140SRaghubansh Kumar
522ce1d69a1SGabriel CarusoWarning: next() expects parameter 1 to be array, int given in %s on line %d
523a541bb80SJani TaskinenNULL
52402dd0140SRaghubansh Kumar
525e5eb9530SAndrea FauldsWarning: next() expects parameter 1 to be array, float given in %s on line %d
526a541bb80SJani TaskinenNULL
52702dd0140SRaghubansh Kumar
528a541bb80SJani TaskinenWarning: next() expects parameter 1 to be array, string given in %s on line %d
529a541bb80SJani TaskinenNULL
53002dd0140SRaghubansh Kumar
531ce1d69a1SGabriel CarusoWarning: reset() expects parameter 1 to be array, int given in %s on line %d
532a541bb80SJani TaskinenNULL
53302dd0140SRaghubansh Kumar
534e5eb9530SAndrea FauldsWarning: reset() expects parameter 1 to be array, float given in %s on line %d
535a541bb80SJani TaskinenNULL
53602dd0140SRaghubansh Kumar
537a541bb80SJani TaskinenWarning: reset() expects parameter 1 to be array, string given in %s on line %d
538a541bb80SJani TaskinenNULL
53902dd0140SRaghubansh KumarDone
540