3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $current = array( 750 => 2, 1000 => 1.3, 2000 => 1.2, 3000 => 1.1, 4000 => 1.0, 5000 => 0.9, 6000 => 0.8, 10000 => 0.75, ); function update($current) { $tiers = array( 0 => 3.5, 250 => 3.5, 500 => 3.5, 750 => 3, ); krsort($current); $prev = 0; foreach($current as $range => $spread) { if ( $range < 1000 ) continue; if ( $range >= 1000 && $range <= 5000 && $spread <= 1.1 ) $spread += 0.4; $prev = $tiers[$range] = max($spread, $prev); } ksort($tiers); return $tiers; } var_dump($current); var_dump(update($current));
Output for 4.3.0 - 7.1.0
array(8) { [750]=> int(2) [1000]=> float(1.3) [2000]=> float(1.2) [3000]=> float(1.1) [4000]=> float(1) [5000]=> float(0.9) [6000]=> float(0.8) [10000]=> float(0.75) } array(11) { [0]=> float(3.5) [250]=> float(3.5) [500]=> float(3.5) [750]=> int(3) [1000]=> float(1.5) [2000]=> float(1.5) [3000]=> float(1.5) [4000]=> float(1.4) [5000]=> float(1.3) [6000]=> float(0.8) [10000]=> float(0.75) }