Re: Re: Split()
| From: | Adam Bregenzer | Date: | Tue, 17 Feb 2004 18:09:33 +0000 |
| Subject: | Re: Re: Split() | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177998@lists.php.net to get a copy of this message | ||
On Tue, 2004-02-17 at 13:01, John Taylor-Johnston wrote:
> $tempauthors = explode("\r\n", $mydata->AuthorList);
> foreach ($tempauthors as $singleauthor)
> # while($tempauthors = each($singleauthor))
> {
> echo "<a
> href=\"http://www.foo.org$singleauthor\">$singleauthor</a>
> ";
> }
First of all, you are flipping your variables:
while ($singleauthor = each($tempauthors))
Secondly, check the manual to see what each() returns[1]. It returns an
array with the key and value of the result in it. If you want to use
each() then you need to evaluate $singleauthor as $singleauthor[0] or
$singleauthor['value'] to get its value. Another way to do this that
would be closer to what foreach does would be:
while (list($key, $singleauthor) = each($tempauthors))
This will assign the key to $key and the value you are looking for to
$singleauthor.
[1] http://www.php.net/each
--
Adam Bregenzer
adam@bregenzer.net
http://adam.bregenzer.net/