PHP Array Goodies: current(), next(), reset(), key()

Sample Code:


$arr = array(
	'a' => 'apple',
	'b' => 'banana',
	'c' => 'coconut',
	'd' => 'doggy'
);

$name = current($arr);
echo $name."
"; $name = next($arr); echo $name."
"; next($arr); $name = current($arr); echo $name."
"; reset($arr); $name = current($arr); echo $name."
"; $key = key($arr); $name = current($arr); echo $key."
";

Output:


apple
banana
coconut
apple
a