"Ashley M. Kirchner" wrote:
>
> Is there a better way to write the following snippet:
>
> if ($priority == "000") {
> $fcol="high";
> $pstr .= "<option value=\"000\" selected>High\n";
> $pstr .= "<option value=\"050\">Medium\n";
> $pstr .= "<option value=\"100\">Low\n";
> } elseif ($priority == "050") {
> $fcol="med";
> $pstr .= "<option value=\"000\">High\n";
> $pstr .= "<option value=\"050\" selected>Medium\n";
> $pstr .= "<option value=\"100\">Low\n";
> } else {
> $fcol="low";
> $pstr .= "<option value=\"000\">High\n";
> $pstr .= "<option value=\"050\">Medium\n";
> $pstr .= "<option value=\"100\" selected>Low\n";
> }
$p_arr=array("000","050","100");
$fc_arr=array("high","med","low");
$ptext_arr("High","Medium","Low");
for($x=0;$x<count($p_arr);$x++)
{ $pstr.="<option value=\"$p_arr[$x]\" ";
if($priority==$p_arr[$x])
{
$pstr.="selected";
$fcol=$fc_arr[$x];
}
$pstr.=">$ptext_arr[$x]\n";
}
You could optimize the code even more if you'd throw $fc_arr away and
use $ptext_arr instead.
Robert
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]