Mecha CMS

Helper functions.

m

Normalize range to the specified boundaries.

2.0.0

m($value, [$old_start, $old_end], [$new_start, $new_end]);

Example:

// Convert range of 0–24 to 0–100
$A = m(12, [0, 24], [0, 100]) . '%';
// Make sure to not exceed the boundaries with `b`
$B = m(b(12345, [0, 24]), [0, 24], [0, 100]) . '%';

Result:

$A = '50%';