Date: 08/10/00
- Next message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #4791 Updated: FTP functions not working?"
- Previous message: pcmaster25 <email protected>: "[PHP-DEV] Bug #6103: Unable to use chmod() or permission denied"
- Next in thread: waldschrott: "Re: [PHP-DEV] Request for comment"
- Reply: waldschrott: "Re: [PHP-DEV] Request for comment"
- Maybe reply: Zak Greant: "Re: [PHP-DEV] Request for comment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
I just fixed a problem with foreach() which has been open a long time.
<?
$a = array("A" => "a", "B" => "b");
$b = $a;
foreach($a as $ka => $va) {
echo "$ka - $va\n";
foreach($b as $kb => $vb) {
echo "$kb - $vb\n";
}
}
?>
What happened here is that $b was effected by the traversing of $a where it
shouldn't have. I have fixed this.
What also works is foreach(array(1,2,3 as $ka => $va)
The main problem is with weird expressions in foreach such as
foreach($a=$b) which would still have such side effect issues. I think this
code is obscure and the change of people using it is slim.
I would like to change foreach to only support:
a) foreach($var) where var could be any variable/multi-dimensionaly
variable ($a[0]).
b) foreach(array(....))
Does anyone see a problem with this? It would mean you can't put obscure
stuff into foreach().
Andi
--- Andi Gutmans <andi <email protected>> http://www.zend.com/-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #4791 Updated: FTP functions not working?"
- Previous message: pcmaster25 <email protected>: "[PHP-DEV] Bug #6103: Unable to use chmod() or permission denied"
- Next in thread: waldschrott: "Re: [PHP-DEV] Request for comment"
- Reply: waldschrott: "Re: [PHP-DEV] Request for comment"
- Maybe reply: Zak Greant: "Re: [PHP-DEV] Request for comment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

