I'm trying to get switch/case to work with some variables and they aren't working and I am wondering why:
function convert_time($time_code) {
switch ($time_code) {
case "8:00a-10:00p":
return 1;
break;
}
}
Then the code that calls this function is:
$testvariable = "8:00a-10:00p";
$testtimecode = covert_time($testvariable);
echo "TTC: $testtimecode";
It always outputs "TTC:"
I went to PhpFiddle and tested it and it also doesn't work there, but I couldn't find a way to make a link to it like in jsfiddle.
However, if I do this code:
$time_code = "8:00a-10:00a";
if ($time_code == "8:00a-10:00a") {echo "yes";} else {echo "no";}
It will echo yes.
So my question is, what about the format of my 8:00a-10:00a is breaking the switch? and is it fixable.
convert_time($testvariable);
(missing n).covert
!=convert
.