|
Posted by Brian Kendig on 04/25/07 19:31
How do I take an index of a literal array, instead of a variable?
That is, say I want to get the short name of a month. Can I do
something like:
$monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec")[$month];
or do I always have to do:
$blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec");
$monthname = $blah[$month];
It seems a shame to have to create a variable specifically for this
one-shot purpose.
Navigation:
[Reply to this message]
|