Re: Split Weirdness.
| From: | Zak Greant | Date: | Mon, 30 Apr 2001 09:41:04 +0000 |
| Subject: | Re: Split Weirdness. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-50834@lists.php.net to get a copy of this message | ||
Nick Davies wrote:
> Why does this work :
>
> $categorySplit = split(",", $row['category']);
>
> while (list($key, $value) = each ( $categorySplit )) {
> $categoryArray["$value"] = 1;
> }
>
> But this not :
>
> while (list($key, $value) = each ( split(",", $row['category']) )) {
> $categoryArray["$value"] = 1;
> }
>
> I keep getting "Maximum execution time of 30 seconds exceeded" errors.
$categorySplit contains an array, while split(",", $row['category']) creates
a new array.
In your second example, you are creating a new array every time that the
while loop runs. This makes the loop condition always true, so the loop runs
til PHP exceeds the max allowed run time.
--zak