请注意,reset() 不会影响多维数组的子数组。
例如,
<?php
$arr = array(
1 => array(2,3,4,5,6),
2 => array(6,7,8,9,10)
);
while(list($i,) = each($arr))
{
echo "IN \$arr[$i]<br>";
while(list($sub_i,$entry) = each($arr[$i]))
{
echo "\$arr[$i][$sub_i] = $entry<br>";
}
}
reset($arr);
while(list($i,) = each($arr))
{
echo "IN \$arr[$i]<br>";
while(list($sub_i,$entry) = each($arr[$i]))
{
echo "\$arr[$i][$sub_i] = $entry<br>";
}
}
?>
将打印
IN $arr[1]
$arr[1][0] = 2
$arr[1][1] = 3
$arr[1][2] = 4
$arr[1][3] = 5
$arr[1][4] = 6
IN $arr[2]
$arr[2][0] = 6
$arr[2][1] = 7
$arr[2][2] = 8
$arr[2][3] = 9
$arr[2][4] = 10
IN $arr[1]
IN $arr[2]