PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
switch($var1, $var2, $var3){
case: blue, furry, peach;
echo "you have a blue furry peach";
break;
default:
echo "you don't have a blue furry peach"
break;
}
This example is minimal but I want to apply that technique in a different function.
If this cannot be done does anyone have any other suggestions?
<?php
$var1="blue";
$var2="furry";
$var3="peach";
if ($var1=="blue" && $var2=="furry" && $var3=="peach")
echo "You have a blue furry peach.";
else
echo "You don't have a blue furry peach";
?>
$v = array("blue", "furry", "peach");
switch($v) {
case array("blue", "furry", "peach"):
echo "you have a blue furry peach";
break;
default:
echo "you don't have a blue furry peach";
break;
}
$v = array("_$GET['color']", "_$GET['state']", "_$GET['fruit']");
switch($v) {
case array("blue", "furry", "peach"):
echo "you have a blue furry peach";
break;
default:
echo "you don't have a blue furry peach";
break;
}
$_GET['color']=$color
$_GET['state']=$state
$_GET['fruit']=$fruit
$v = array($color, $state, $fruit);
switch($v) {
case array("blue", "furry", "peach"):
echo "you have a blue furry peach";
break;
default:
echo "you don't have a blue furry peach";
break;
}
switch(array($_GET['color'], $_GET['state'], $_GET['fruit'])) {
case array("blue", "furry", "peach"):
echo "you have a blue furry peach";
break;
default:
echo "you don't have a blue furry peach";
break;
}