Returns the next element.
The next() function moves the internal pointer of an array to the next element and returns that element.
<?php
$array1 = array(21, 53, 5, 8, 32, 77);
while ($element = current($array1)) {
if ($element % 2 == 0)
break;
next($array1);
}
print "The first element divisible by 2: $element";
?>
The first element divisible by 2: 8
The code looks for the first element divisible by two in an array.