<?php
$items = array('A'=>'Apple', 'B'=>'Bee', 'C'=>'Candy');
var_dump(next($items)); // string(3) "Bee" because next() returns next element and advances pointer to next element
foreach($items as $element) {
echo $element,PHP_EOL; // print all of $items elements
}
var_dump(current($items)); // Should be 'string(3) "Bee"' because next() is called before foreach, but returns FALSE
reset($items);
var_dump(current($items)); // string(5) "Apple". reset() called. It should be "Apple".
string(3) "Bee"
Apple
Bee
Candy
bool(false)
string(5) "Apple"
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/HbVnd on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
string(3) "Bee"
Apple
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HbVnd on line 5
PHP_EOLBee
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HbVnd on line 5
PHP_EOLCandy
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/HbVnd on line 5
PHP_EOLbool(false)
string(5) "Apple"