Re: professional code quick tip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



in other languages it is possible use conditional epression in switch case
like
switch $n

case (0<n<=4):
........

but no in php

You could use the following statement:

<?php
switch (true) {
case (0 < $n <= 4):
$f = 1;
break;
case (5 < $n <= 7):
$f = 2;
break;
case (8 < $n <= 12):
$f = 3;
break;
default:
$f = 4;
break;
}
?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux