Tim Ward
> Senior Systems Engineer
>
> Please refer to the following disclaimer in respect of this message:
> http://www.stivesdirect.com/e-mail-disclaimer.html
>
>
> > -Original Message-----
> > From: Maxim Derkachev [mailto:[EMAIL PROTECTED]]
respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -Original Message-
> From: Maxim Derkachev [mailto:[EMAIL PROTECTED]]
> Sent: 12 April 2001 16:23
> To: Tim Ward
> Cc: [EMAIL PROTECTED]
> Subject: Re[2]: [PHP] foreach vs. while(list() = e
Hello Tim,
Thursday, April 12, 2001, 1:43:53 PM, you wrote:
TW> you can't nest foreach as you should be able to. Ecah foreach is supposed to
TW> have it's own pointer in the array, but it doesn't ... this is a known bug.
What do you mean? Foreach() can be nested, and it works perfect.
$first)
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
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
/***
11 matches
Mail list logo