I was wondering if someone have had the same problem. My code first:
<?php
$testArray = [
['name' => 'one', 'value' => 10],
['name' => 'two', 'value' => 15],
['name' => 'three', 'value' => 8]
];
foreach ($testArray as &$testArrayRow) {
$testArrayRow['value'] += 10;
echo '<div>'.$testArrayRow['name'].' = '.$testArrayRow['value'].'</div>';
}
foreach ($testArray as $testArrayRow) {
echo '<div>'.$testArrayRow['name'].' = '.$testArrayRow['value'].'</div>';
}
?>
Output below:
one = 20 two = 25 three = 18 one = 20 two = 25 two = 25
While I expect this:
one = 20 two = 25 three = 18 one = 20 two = 25 three = 18
Anyone who can tell me what is happening?
Thanks in advance!