Re: simplify if/then statement
| From: | Pekka Saarinen | Date: | Sat, 27 Apr 2002 18:52:16 +0000 |
| Subject: | Re: simplify if/then statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94933@lists.php.net to get a copy of this message | ||
Hi,
Make an array $arr of all the states and loop
$state = "AR";
$arr = array();
array_push($arr, "AL", "AR", "AZ");
foreach ($arr as $key => $value)
{
if ($state == $value){
include("Calc$value.class.inc");
}
}
Cheers,
Pekka
http://photography-on-the.net/
At 4/27/2002, you wrote:
Hi, I've got the following statement for a state options menu. How can this be expressed in a simple manner for all 52 states? //choose state if ($state == "AL") { // include class include("CalcAL.class.inc"); } else if ($state == "AR") { // include class include("CalcAR.class.inc"); } else if ($state == "AZ") { // include class include("CalcAZ.class.inc"); } else{ echo "Please select a State.<br>\n"; } Thank You Very Much, Jim Long -- http://jimlong.net/web -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php