Re: While-else
| From: | Andrew Brampton | Date: | Thu, 03 May 2007 07:34:41 +0000 |
| Subject: | Re: While-else | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-29135@lists.php.net to get a copy of this message | ||
----- Original Message -----
On Sat, April 28, 2007 1:03 pm, Pelle Ravn Rosfeldt wrote:I have wanted to use this kind of syntax a couple of times, for example: <?php while ($line = mysql_fetch_array(...)) { echo $line; } else { echo 'Sorry no records'; } ?> Otherwise I would write the above code as a while + a if. However I'm unsure if this syntax should be put into PHP, but I thought I'll just post a example of when I would use it. thanks AndrewIs it possible to make a "while" with a "else"-statement in PHP6? I know that it's not the first time this subject is up, but my research shows that a lot of people miss it. Including me. Here's an example of what I mean: --------------------- <? $i = 1; while ($i <= 10) {echo $i++;} else {echo "The while couldn't be executed!";} ?> ---------------------