Re: foreach - Array
- From: Alan Little <alan@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 30 May 2006 15:19:36 -0500
Carved in mystic runes upon the very living rock, the last words of David
Haynes of comp.lang.php make plain:
iavian wrote:
hiforeach( $array as &$ele ) {
i want to modify an array in foreach loop
foreach($array as $ele){
$ele = $some_random_string;
}
i should see here the modified $array .
thnaks in advance
$ele = $some_random_string;
}
should work as you want it to.
Only in PHP5.
http://us3.php.net/manual/en/control-structures.foreach.php
"Unless the array is referenced, foreach operates on a copy of the
specified array and not the array itself....As of PHP 5, you can easily
modify array's elements by preceding $value with &. This will assign
reference instead of copying the value."
--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
.
- References:
- foreach - Array
- From: iavian
- Re: foreach - Array
- From: David Haynes
- foreach - Array
- Prev by Date: Re: php mail() issues
- Next by Date: Re: From $20 to $300 ??
- Previous by thread: Re: foreach - Array
- Next by thread: Re: foreach - Array
- Index(es):
Relevant Pages
|