note 102897 deleted from control-structures.do.while by cmb
| From: | cmb@php.net | Date: | Sun, 04 Dec 2016 12:24:47 +0000 |
| Subject: | note 102897 deleted from control-structures.do.while by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208212@lists.php.net to get a copy of this message | ||
Note Submitter: xiaomao5 at live dot com
----
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);
?>