Re: looping through array with list()/each()
| From: | Erwin | Date: | Wed, 25 Sep 2002 12:04:28 +0000 |
| Subject: | Re: looping through array with list()/each() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117555@lists.php.net to get a copy of this message | ||
> Please cast an eye over the following code and output and tell me why
> $k and $v are not being set:
>
>
> Code:
> -----------------------------
>
> $ser = array( 'first', 'second', 'third', 'fourth',
> 'fifth' );
>
> reset($ser);
> while ( list($key, $val) = each($ser) );
> {
> echo "\$key = $key, \$val = $val<br>";
> }
Small typo:
while ( list($key, $val) = each($ser) );
change into:
while ( list($key, $val) = each($ser) )
Remove the ";"
HTH
Erwin
P.S.: Take a break ;-))