3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $grades = array( "PK", "K", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" ); function normalizeLexileScore($ability, $grade_level = null) { $grade_level = (int)$grade_level; if( $grade_level == null ) { return $ability; } $grade_level = max(min($grade_level, 9), 2); echo " > $grade_level\n"; $gli_cap = array(NULL, NULL, 975, 1070, 1165, 1250, 1300, 1370, 1420, 1500); $normalized = min($ability, $gli_cap[$grade_level]); return $normalized; } foreach ($grades as $grade) { printf("%d, %s\n", normalizeLexileScore(1000, $grade), $grade); }
based on MTIQG
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
1000, PK 1000, K > 2 975, 01 > 2 975, 02 > 3 1000, 03 > 4 1000, 04 > 5 1000, 05 > 6 1000, 06 > 7 1000, 07 > 8 1000, 08 > 9 1000, 09 > 9 1000, 10 > 9 1000, 11 > 9 1000, 12