My associative array.
$money = array("Nickels" => $_POST["nickels"], "Dimes" => $_POST["dimes"], "Quarters" =>$_POST["quarters"]);
My html form set up to handle Quarters, Dimes and Nickels are not shown in this case for brevity.
<label><b>Quarters:</b></label>
<select name="quarters" >
<option value=".25">25c</option>
<option value=".50">50c</option>
<option value=".75">75c</option>
<option value="1">$1.00</option>
</select>
A user can only select either Quarters only, Dimes only, or Nickels only. If a user selects Quarters with the option value of .25, this value will be sent to the php script.
So I was just wondering for calculations based on the fact that the user can select Quarters only with one value, Dimes only with one value, and Nickels only with one value, and not a combination of denominations,
how would one go about setting up different test cases, for example if the user selects
$money["Quarters"];
// With different values coming from the html form as .25, .50,.75, or 1, and only one of the selected values will make it through to the php script depending on what the user selected.
Can I do this:
switch($selection)
{
case “Quarters”:
echo “ You chose $money[‘Quarters’]; .<br />”;
break;
case “Nickels”:
echo “You chose $money[‘Nickels’]; .<br />”;
break;
case “Dimes”:
echo “You chose $money[‘Dimes’]; . <br />”;
break;
default: print “Please select a Denomination”;
}
Thank you for not flaming the newb, I am still learning, and sorry for the mix and match in terms of "
and “
.