- current: documentation ( source)
<?php
$arr = ['one', 'two', 'three', 'four', 'five'];
echo 'Current value: ' . current($arr) . "\n";
foreach ($arr as $a)
{
if ($a === 'three') break;
}
echo 'Did it change? ' . current($arr) . "\n";
function withRef(array &$arr): void
{
foreach ($arr as $a)
{
if ($a === 'three') break;
}
}
withRef($arr);
echo 'What about now? ' . current($arr) . "\n";