Source Code:
(back to article)
<?php $colors = ['red', 'green', 'blue']; // Set the current position to the first element reset($colors); // Retrieve the value of the element at the current position echo pos($colors) . '-'; // Output: red // Move the current position to the next element next($colors); // Retrieve the value of the element at the current position echo pos($colors) . '-'; // Output: green // Move the current position to the next element next($colors); // Retrieve the value of the element at the current position echo pos($colors); // Output: blue
Result:
Report an issue