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)
String can be accessed like array, but foreach does not handle invalid parameter
well.
While() does not misbehave with equivalent code.
Regards,
--
Yasuo Ohgaki
"Joe Stump" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> What are the differences in these? I know with while() you have to reset() the
> array afterwards, but foreach() you don't. Also foreach() appears to be quite
> a bit faster.
>
> My main question is there ANY difference in how these two loop through the
> array.
>
> --Joe
>
>
>
>
/******************************************************************************\
> * Joe Stump - PHP/SQL/HTML Developer
*
> * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net
*
> * "Better to double your money on mediocrity than lose it all on a dream."
*
>
\******************************************************************************/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]