Keyword proposal: in
| From: | Alex Kiesel | Date: | Wed, 06 Feb 2002 16:25:15 +0000 |
| Subject: | Keyword proposal: in | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-79369@lists.php.net to get a copy of this message | ||
Hi,
I'd like to propose a new keyword: in. It should work like the
SQL-in-expression.
For example you have a variable $val and want to test whether it
contains e.g. 1 or 2 or 99.
At the moment I would choose between on of the following
code-constructs:
1.) if ($var == 1 ||
$var == 2 ||
$var == 99) { // ...
2.) if (in_array ($var, array (1, 2, 99)) { // ...
What about adopting such a keyword as in to be able to write the
following code:
if ($var in (1, 2, 99)) { // ...
Well, at least I find it quite elegant. :)
I'd appreciate any comments.
Alex
--
Alex Kiesel PGP Key: 0x09F4FA11
Todays excuse: Secretary sent chain letter to all 5000 employees.