- ceil: documentation ( source)
- range: documentation ( source)
<?php
function convert($input)
{
$oldMin = 0;
$oldMax = 1;
$newMin = 127;
$newMax = 0;
return ceil(((($input- $oldMin) * ($newMax - $newMin)) / ($oldMax - $oldMin)) + $newMin);
}
foreach (range(0,1,1/1000) as $input) {
convert($input);
}