foreach by reference
Posted: Tue Jun 28, 2005 9:09 pm
Hi,
Just a quick PHP 4 question. I've tried the following which doesn't work (assume $objects is an array of some generic object):
This doesn't actually change the values in $objects at all because they're passed by value rather than by reference. In other words, $item is a copy of an item in the objects array, not the object itself.
I was just wondering if there was a way to use a foreach loop in PHP4 by reference?
Just a quick PHP 4 question. I've tried the following which doesn't work (assume $objects is an array of some generic object):
Code: Select all
foreach($objects as $item)
{
$item->setValue($value);
}I was just wondering if there was a way to use a foreach loop in PHP4 by reference?