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) { 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 pCs8f
Output for 5.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
> 2 975, PK > 2 975, K > 2 975, 01 > 02 Notice: Undefined index: 02 in /in/jNFqG on line 30 0, 02 > 03 Notice: Undefined index: 03 in /in/jNFqG on line 30 0, 03 > 04 Notice: Undefined index: 04 in /in/jNFqG on line 30 0, 04 > 05 Notice: Undefined index: 05 in /in/jNFqG on line 30 0, 05 > 06 Notice: Undefined index: 06 in /in/jNFqG on line 30 0, 06 > 07 Notice: Undefined index: 07 in /in/jNFqG on line 30 0, 07 > 08 Notice: Undefined index: 08 in /in/jNFqG on line 30 0, 08 > 09 Notice: Undefined index: 09 in /in/jNFqG on line 30 0, 09 > 9 1000, 10 > 9 1000, 11 > 9 1000, 12
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 5.2.17
> 2 975, PK > 2 975, K > 2 975, 01 > 02 Notice: Undefined index: 02 in /in/jNFqG on line 30 0, 02 > 03 Notice: Undefined index: 03 in /in/jNFqG on line 30 0, 03 > 04 Notice: Undefined index: 04 in /in/jNFqG on line 30 0, 04 > 05 Notice: Undefined index: 05 in /in/jNFqG on line 30 0, 05 > 06 Notice: Undefined index: 06 in /in/jNFqG on line 30 0, 06 > 07 Notice: Undefined index: 07 in /in/jNFqG on line 30 0, 07 > 08 Notice: Undefined index: 08 in /in/jNFqG on line 30 0, 08 > 09 Notice: Undefined index: 09 in /in/jNFqG on line 30 0, 09 > 9 1000, 10 > 9 1000, 11 > 9 1000, 12