Re: list(), each()
| From: | Rasmus Lerdorf | Date: | Mon, 25 Mar 2002 17:18:21 +0000 |
| Subject: | Re: list(), each() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90056@lists.php.net to get a copy of this message | ||
Why do you put each(explode()) ? Just list() = explode() is what you
want.
-Rasmus
On Mon, 25 Mar 2002, Chris Boget wrote:
> Ok, I've got to be doing something wrong here. I've been
> beating my head up against the wall for some time and I
> just cannot figure out what it is. Before I say it's a bug with
> list(), could someone tell me what I'm doing wrong?
>
> <?
>
> $policy = "1016726726--1--1016643856";
>
> // problematic
> list( $policy_num, $policy_year, $application_reference ) = each( explode( "--",
> $policy ));
> echo "list( $policy_num, $policy_year, $application_reference ) = each( explode(
> \"--\", $policy )); <br>\n";
>
> // fine
> $policy = explode( "--", $policy );
> echo $policy[0] . "<br>\n";
> echo $policy[1] . "<br>\n";
> echo $policy[2] . "<br>\n";
>
> ?>
>
> Why isn't list() assigning the value properly? For the first echo statement, I'm
> getting:
>
> "list( 0, 1016726726, ) = each( explode( "--", 1016726726--1--1016643856
> ));"
>
> but the others, where I'm echoing out the individual elements, it's working fine.
>
> What's going on?
>
> Chris
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>