RE: [PHP] Why is this code hanging?
| From: | John Holmes | Date: | Tue, 02 Jul 2002 08:54:27 +0000 |
| Subject: | RE: [PHP] Why is this code hanging? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104861@lists.php.net to get a copy of this message | ||
You're not incrementing $count within your while loop. So it's staying
at zero the whole time...
---John Holmes...
> -----Original Message-----
> From: Leif K-Brooks [mailto:eurleif@buyer-brokerage.com]
> Sent: Tuesday, July 02, 2002 4:31 AM
> To: php-general@lists.php.net
> Subject: [PHP] Why is this code hanging?
>
> I am trying to make a simple php program to produce text lIkE tHiS.
> The thing is, it hangs for a while andd then says it's reached the
> maximum execution time of 30 seconds. The error is on line 18. Any
> ideas? My code:
> <?php
> print "<html><body>";
> if(!isset($_POST['text'])){
> print <<< END
> <form action="case.php" method="post">
> <b>Text:</b> <input type="text" name="text" /><br
> />
> <input type="submit" value="Do" /></form>
> END;
> }else{
> $text = $_POST['text'];
> $last = false;
> $final = "";
> $count = 0;
> while($count < strlen($text)){
> $this = $text{$count};
> if(ereg("[a-zA-Z]",$this)){
> if($last){
> $final = $final.strtolower($this);
> $last = false;
> }else{
> $final = $final.strtoupper($this);
> $last = true;
> }
> }
> }
> print $final;
> }
> print "</body></html>";
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php