Re: simplify if/then statement

From: Date: Sat, 27 Apr 2002 18:09:19 +0000
Subject: Re: simplify if/then statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94929@lists.php.net to get a copy of this message
On Sat, 27 Apr 2002, Jim Long wrote: > I've got the following statement for a state options menu. > How can this be expressed in a simple manner for all 52 states? switch(strtolower($state)) { case 'al': include 'CalcALclass.inc'; break; case 'ar': include 'CalcALclass.inc'; break; } Or, really, just: include "Calc{$state}class.inc"; miguel > //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 >

« previous php.general (#94929) next »