Possible Duplicate:
In PHP given a month string such as “November” how can I return 11 without using a 12 part switch statement?
I have weekdays in a specific format that I need to convert to another format and ultimately translate them, as well. I need to do this at runtime, meaning I cannot change the format in which the dates are stored, but have to convert them for the final output on the website.
Now, of course I could just create seven if-statements to do this, like
if ($wkday == "Mon") { $wkday = "Monday"; }
if ($wkday == "Tue") { $wkday = "Tuesday"; }
…
But I’m trying to find a neater way to do this, like putting both input and output values in arrays and comparing them to one another, to cut down the number of ugly if-statements. It’s not so bad in this case, seeing that there are only seven possible values, but I’d like to do it right and learn for the future. 🙂 I tried to search for this, but don’t even know what terminology to use. I’ll be grateful for any hint.
Thanks for you help!
An array would be useful here, and in this case it would be similar to a hashmap in Java.
PHP manual link on arrays