CodeSOD: Monthly Totals
by Remy Porter from The Daily WTF on (#6H3VP)
Daniel spotted an array called $months in a PHP application. The data being stored in the array was some total of the sales of some commodity, for the past 5 months.
That much all made sense. What didn't make sense was how the array was indexed.
$months = array('o' => 23141, 't' => 23142, 'th' => 42432, 'f' => 63243, 'fi' => 21422);
The keys aren't numbers, but the keys represent numbers. One, two, three, four, and five, to be exact.
Many, many times, I've seen maps misused to be arrays, where the keys are just indexes. But I've never seen them abused like this- a magical, cryptic code that only the developer responsible for this horror could love.
[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!