lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at
PHP: proximity loop
What do I mean by that? Say you want to figure out the proximity of months where Jan = 1 and Dec = 12. Can't just subtract the values. So need to do something like this:

$diff = abs($month1 - $month2) > 6 ? 12 - abs($month1 - $month2) : abs($month1 - $month2);

keywords: month, cycle, difference, proximity