Thanks for this great feature!
I would personally improve this feature a bit by adding a simple error check to avoid dividing by 0, which would make PHP a fatal error.
function map($value, $low1, $high1, $low2, $high2) { if ($low1 == $high1) return $low1; return ($value / ($high1 - $low1)) * ($high2 - $low2) + $low2; }
Bernz source share