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, $cast = false) { if( $grade_level == null ) { return $ability; } if ($cast) { $grade_level = (int)$grade_level; } $grade_level = max(min($grade_level, 9), 2); $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) { $minBad = normalizeLexileScore(0, $grade, false); $maxBad = normalizeLexileScore(2000, $grade, false); $minGood = normalizeLexileScore(0, $grade, true); $maxGood = normalizeLexileScore(2000, $grade, true); printf("Grade %s: Bad: %d < %d, Good: %d < %d\n", $grade, $minBad, $maxBad, $minGood, $maxGood); }
based on Aj33d
Output for 5.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Grade PK: Bad: 0 < 975, Good: 0 < 975 Grade K: Bad: 0 < 975, Good: 0 < 975 Grade 01: Bad: 0 < 975, Good: 0 < 975 Notice: Undefined index: 02 in /in/U4WGI on line 32 Notice: Undefined index: 02 in /in/U4WGI on line 32 Grade 02: Bad: 0 < 0, Good: 0 < 975 Notice: Undefined index: 03 in /in/U4WGI on line 32 Notice: Undefined index: 03 in /in/U4WGI on line 32 Grade 03: Bad: 0 < 0, Good: 0 < 1070 Notice: Undefined index: 04 in /in/U4WGI on line 32 Notice: Undefined index: 04 in /in/U4WGI on line 32 Grade 04: Bad: 0 < 0, Good: 0 < 1165 Notice: Undefined index: 05 in /in/U4WGI on line 32 Notice: Undefined index: 05 in /in/U4WGI on line 32 Grade 05: Bad: 0 < 0, Good: 0 < 1250 Notice: Undefined index: 06 in /in/U4WGI on line 32 Notice: Undefined index: 06 in /in/U4WGI on line 32 Grade 06: Bad: 0 < 0, Good: 0 < 1300 Notice: Undefined index: 07 in /in/U4WGI on line 32 Notice: Undefined index: 07 in /in/U4WGI on line 32 Grade 07: Bad: 0 < 0, Good: 0 < 1370 Notice: Undefined index: 08 in /in/U4WGI on line 32 Notice: Undefined index: 08 in /in/U4WGI on line 32 Grade 08: Bad: 0 < 0, Good: 0 < 1420 Notice: Undefined index: 09 in /in/U4WGI on line 32 Notice: Undefined index: 09 in /in/U4WGI on line 32 Grade 09: Bad: 0 < 0, Good: 0 < 1500 Grade 10: Bad: 0 < 1500, Good: 0 < 1500 Grade 11: Bad: 0 < 1500, Good: 0 < 1500 Grade 12: Bad: 0 < 1500, Good: 0 < 1500
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 5.2.17
Grade PK: Bad: 0 < 975, Good: 0 < 975 Grade K: Bad: 0 < 975, Good: 0 < 975 Grade 01: Bad: 0 < 975, Good: 0 < 975 Notice: Undefined index: 02 in /in/U4WGI on line 32 Notice: Undefined index: 02 in /in/U4WGI on line 32 Grade 02: Bad: 0 < 0, Good: 0 < 975 Notice: Undefined index: 03 in /in/U4WGI on line 32 Notice: Undefined index: 03 in /in/U4WGI on line 32 Grade 03: Bad: 0 < 0, Good: 0 < 1070 Notice: Undefined index: 04 in /in/U4WGI on line 32 Notice: Undefined index: 04 in /in/U4WGI on line 32 Grade 04: Bad: 0 < 0, Good: 0 < 1165 Notice: Undefined index: 05 in /in/U4WGI on line 32 Notice: Undefined index: 05 in /in/U4WGI on line 32 Grade 05: Bad: 0 < 0, Good: 0 < 1250 Notice: Undefined index: 06 in /in/U4WGI on line 32 Notice: Undefined index: 06 in /in/U4WGI on line 32 Grade 06: Bad: 0 < 0, Good: 0 < 1300 Notice: Undefined index: 07 in /in/U4WGI on line 32 Notice: Undefined index: 07 in /in/U4WGI on line 32 Grade 07: Bad: 0 < 0, Good: 0 < 1370 Notice: Undefined index: 08 in /in/U4WGI on line 32 Notice: Undefined index: 08 in /in/U4WGI on line 32 Grade 08: Bad: 0 < 0, Good: 0 < 1420 Notice: Undefined index: 09 in /in/U4WGI on line 32 Notice: Undefined index: 09 in /in/U4WGI on line 32 Grade 09: Bad: 0 < 0, Good: 0 < 1500 Grade 10: Bad: 0 < 1500, Good: 0 < 1500 Grade 11: Bad: 0 < 1500, Good: 0 < 1500 Grade 12: Bad: 0 < 1500, Good: 0 < 1500