Switch/case string comparison is case-sensitive.
<?php
$smart = "crikey";
switch ($smart) {
case "Crikey":
echo "Crikey";
break;
case "Hund":
echo "Hund";
break;
case "Kat":
echo "Kat";
break;
default:
echo "Alt Andet";
}
?>
Above code prints "Alt Andet", but I would like to compare strings case-insensitively and print "Crikey". How can I do that?
crikeyandCrikeyaren't the same. Knowing that, work around it andstrtoupperorstrtolowerthe values. Alternatively, uppercase the 1st letter of your variable when doing comparisons. Also, why would you want it that way anyway?