Re: Bug #15663: add foreach reference values
| From: | Andrey Hristov | Date: | Thu, 21 Feb 2002 17:43:29 +0000 |
| Subject: | Re: Bug #15663: add foreach reference values | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80278@lists.php.net to get a copy of this message | ||
This FR is known :))
Best wishes,
Andrey Hristov
----- Original Message -----
From: <greg@mtechsolutions.ca>
To: <php-bugs@lists.php.net>
Sent: Thursday, February 21, 2002 7:34 PM
Subject: Bug #15663: add foreach reference values
> From: greg@mtechsolutions.ca
> Operating system:
> PHP version: 4.1.1
> PHP Bug Type: Feature/Change Request
> Bug description: add foreach reference values
>
> Just a small request that could be fairly useful.
>
> Say you have an array of objects, $objects. Right now, doing:
>
> foreach ($objects as $obj) {
> $obj->something();
> }
>
> will create a copy of each object (using unnecessary memory) and call
> something() on the copy, not the actual object (which is bad if it's a
> mutator function of that class).
>
> The best way to do it now is to do:
>
> foreach (array_keys($objects) as $key) {
> $objects[$key]->something();
> }
>
> but it would be very cool if php had the syntax:
>
> foreach ($objects as &$obj)
>
> where it would create $obj as a reference to each object.
>
> thanks
> --
> Edit bug report at http://bugs.php.net/?id=15663&edit=1
> --
> Fixed in CVS:
> http://bugs.php.net/fix.php?id=15663&r=fixedcvs
> Fixed in release:
> http://bugs.php.net/fix.php?id=15663&r=alreadyfixed
> Need backtrace:
> http://bugs.php.net/fix.php?id=15663&r=needtrace
> Try newer version:
> http://bugs.php.net/fix.php?id=15663&r=oldversion
> Not developer issue:
> http://bugs.php.net/fix.php?id=15663&r=support
> Expected behavior:
> http://bugs.php.net/fix.php?id=15663&r=notwrong
> Not enough info:
> http://bugs.php.net/fix.php?id=15663&r=notenoughinfo
> Submitted twice:
> http://bugs.php.net/fix.php?id=15663&r=submittedtwice
>
>