I can’t figure out why this isn’t working, and I know it’s because of ssome simple stupid mistake.
Could you please help me out?
$p = 'aM';
function FormatPeriod($p) {
$periodFormated = 'null';
switch($p){
case "am": $periodFormated = "AM"; break;
case "Am": $periodFormated = "AM"; break;
case "aM": $periodFormated = "AM"; break;
case "pm": $periodFormated = "PM"; break;
case "Pm": $periodFormated = "PM"; break;
case "pM": $periodFormated = "PM"; break;
default: $periodFormated = 'fail';
}
return $periodFormated;
}
$periodFormated = FormatDate($p);
Sadly, the output is “aM”.
Why didn’t the string change to “AM”?
~Thank you.
You just need is
if it is a user input you just need to add one more check
and you are calling different function to format. You should call
FormatPeriodand you are callingFormatDate