1--TEST-- 2Test current() function : usage variations - multi-dimensional arrays 3--FILE-- 4<?php 5/* 6 * Test how current() behaves with muti-dimensional and recursive arrays 7 */ 8 9echo "*** Testing current() : usage variations ***\n"; 10 11echo "\n-- Two Dimensional Array --\n"; 12$multi_array = array ('zero', array (1, 2, 3), 'two'); 13echo "Initial Position: "; 14var_dump(current($multi_array)); 15 16echo "Next Position: "; 17next($multi_array); 18var_dump(current($multi_array)); 19 20echo "End Position: "; 21end($multi_array); 22var_dump(current($multi_array)); 23 24echo "\n-- Access an Array Within an Array --\n"; 25//accessing an array within an array 26echo "Initial Position: "; 27var_dump(current($multi_array[1])); 28 29echo "\n-- Recursive, Multidimensional Array --\n"; 30//create a recursive array 31$multi_array[] = &$multi_array; 32 33//See where internal pointer is after adding more elements 34echo "Current Position: "; 35var_dump(current($multi_array)); 36 37//see if internal pointer is in same position as referenced array 38var_dump(current($multi_array[3][3][3])); 39// see if internal pointer is in the same position from when accessing this inner array 40var_dump(current($multi_array[3][3][3][1])); 41?> 42--EXPECT-- 43*** Testing current() : usage variations *** 44 45-- Two Dimensional Array -- 46Initial Position: string(4) "zero" 47Next Position: array(3) { 48 [0]=> 49 int(1) 50 [1]=> 51 int(2) 52 [2]=> 53 int(3) 54} 55End Position: string(3) "two" 56 57-- Access an Array Within an Array -- 58Initial Position: int(1) 59 60-- Recursive, Multidimensional Array -- 61Current Position: string(3) "two" 62string(3) "two" 63int(1) 64