Given the array below, can I do this for the switch(use the variable $cost inside the switch)?
Or does the switch($need a different variable here)
$cost=array(chocoru =>1, oeenergy =>0.35, lemondew =>0.55, chcmyst =>0.25, drsalty =>0.75);
Notice the $cost variable inside the switch is the same as the $cost associative array.
switch($cost)
{
case 1:
echo "You chose lemondew <br />";
echo "the price is".$cost["lemondew"]'<br>';
}
No, you have to iterate over the array with a loop.