The foreach
constructor provides an easy way to iterate over arrays . In several scripts we can observe the following usage:
foreach ($array as $value) {
$value = $value * 2;
}
However, in some cases the following use is possible:
foreach ($array as &$value) {
$value = $value * 2;
}
What exactly would be the character &
accompanied by the variable $value
, and what its effect inside the command foreach
?