s message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -Original Message-
> From: Yasuo Ohgaki [mailto:[EMAIL PROTECTED]]
> Sent: 12 April 2001 02:37
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] foreach vs. while(list() = each())
>
>
> One apparent problem with foreach()
@ 3:45:39 AM on 4/12/2001, Brian Clark wrote:
...
>> You don't need to reset() the array, You also don't need list() and
>> each(), which impose additional overhead. You put the array loop to
>> the foreach() implementation, which is in C, instead of
>> implementing it with PHP with while(), lis
Hi Maxim,
@ 3:39:55 AM on 4/12/2001, Maxim Derkachev wrote:
> Hello Joe,
> Wednesday, April 11, 2001, 10:49:31 PM, you wrote:
JS>> What are the differences in these? I know with while() you have to reset() the
JS>> array afterwards, but foreach() you don't. Also foreach() appears to be quite
J
Hello Joe,
Wednesday, April 11, 2001, 10:49:31 PM, you wrote:
JS> What are the differences in these? I know with while() you have to reset() the
JS> array afterwards, but foreach() you don't. Also foreach() appears to be quite
JS> a bit faster.
You don't need to reset() the array, You also don
I believe foreach also works on a copy basis, not a pointer or reference. So
if you try and alter the array you are foreach'ing it won't work as
expected.
For instance this:
$array = array("var1", "var2", "var3");
foreach ($array as $val)
{
if ($val == "var2")
{
$val = "changed2";
}
}
pr
> 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 y
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
7 matches
Mail list logo