PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to run through an array with a foreach loop, but I need to value which is passed from the foreach iteration to be a reference so that when I make a change, it will stick.
foreach($selection as $select) {
if ($select == 1) {
$select = 2;
}
}
This is just an example. But when this foreach loop ends. Any value that was 1 is not changed to 2 because only a copy of the value of $selection was passed in, not a reference.
I've tried the following and only get parse errors: