Re: foreach vs. while(list() = each())
| From: | Lewis Bergman | Date: | Thu, 12 Apr 2001 02:30:01 +0000 |
| Subject: | Re: foreach vs. while(list() = each()) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48231@lists.php.net to get a copy of this message | ||
> One apparent problem with foreach() is it can misbehave code as
> follows. (4.0.4pl1, 4.0.5RC6)
>
> function foo($a) {
> foreach ($a[0] as $k => $v) {
> echo $k.$v;
> }
> }
>
> $a = 'abc';
> foo($a);
>
> You'll get 'server not found' or browser waiting forever with this
> code. (If you don't, please let me know)
>
Good point but I wouldn't characterize a launguage's or function's
expectation that you use correct syntax as a problem.