note 102897 modified in control-structures.do.while by danbrown
| From: | danbrown@php.net | Date: | Sun, 13 Mar 2011 16:18:39 +0000 |
| Subject: | note 102897 modified in control-structures.do.while by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177842@lists.php.net to get a copy of this message | ||
Another hack
If you want $type to only have a value of 0 or 1, you can do this:
<?php
do {
echo 'Choose a type, 0 or 1: ';
$type = trim(fgets(STDIN));
if ($type == 0) {
/* do stuff */
} elseif ($type == 1) {
/* do stuff */
}
} while ($type != 0 && $type != 1);
?>
--was--
Another hack
If you want $type to only have a value of 0 or 1, you can do this:
do {
echo 'Choose a type, 0 or 1: ';
$type = trim(fgets(STDIN));
if ($type == 0) {
/* do stuff */
} elseif ($type == 1) {
/* do stuff */
}
} while ($type != 0 && $type != 1);
http://php.net/manual/en/control-structures.do.while.php