Welcome to WebmasterWorld Guest from 126.96.36.199
I later need to assign a numeric value to their choice, but rather than doing multiple ifs
if($Fruit == "apples")
$FruitValue = 120;
elseif ($Fruit == "oranges")
$FruitValue = 80;
is there a way to do this in one go, without all the ifs?
joined:Nov 12, 2005
$fruit = array("apples" => 120, "oranges" => 80);
$FruitValue = $fruit[$Fruit];
You might want to check to see if the index exists in the array before you actually do what I have shown above, but this should work out a little better for you.