3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv=<<<CSV Tom Brady,NE,385,581,4577,32,8 Philip Rivers,LAC,360,575,4515,28,10 Matthew Stafford,DET,371,565,4446,29,10 Drew Brees,NO,386,536,4334,23,8 Ben Roethlisberger,PIT,360,561,4251,28,14 Matt Ryan,ATL,342,529,4095,20,12 Kirk Cousins,WAS,347,540,4093,27,13 Alex Smith,KC,341,505,4042,26,5 Russell Wilson,SEA,339,553,3983,34,11 Jared Goff,LA,296,477,3804,28,7 Blake Bortles,JAX,315,523,3687,21,13 Case Keenum,MIN,325,481,3547,22,7 Jameis Winston,TB,282,442,3504,19,11 Derek Carr,OAK,323,515,3496,22,13 Eli Manning,NYG,352,571,3468,19,13 Dak Prescott,DAL,308,490,3324,22,13 Andy Dalton,CIN,297,496,3320,25,12 Cam Newton,CAR,291,492,3302,22,16 Carson Wentz,PHI,265,440,3296,33,7 Marcus Mariota,TEN,281,453,3232,13,15 Joe Flacco,BAL,352,549,3141,18,13 Jacoby Brissett,IND,276,469,3098,13,7 Josh McCown,NYJ,267,397,2926,18,9 CSV; function Calculate($completions, $attempts, $yards, $touchdowns, $interceptions){ $result=[ min(2.375, ($completions/$attempts - .3) * 5), min(2.375, ($yards/$attempts - 3) * .25), min(2.375, $touchdowns/$attempts * 20), min(2.375, 2.375 - ($interceptions/$attempts *25)) ]; return round(array_sum($result)/6*100, 2); // calculated passingRate } foreach(explode("\n",$csv) as $line){ list($name,$team,$completions,$attempts,$yards,$touchdowns,$interceptions)=str_getcsv($line,","); $NFL_Stats[]=['team'=>$team,'name'=>$name,'passingRate'=>Calculate($completions, $attempts, $yards, $touchdowns, $interceptions)]; } usort($NFL_Stats,function($a,$b){return $b['passingRate']<=>$a['passingRate'];}); // order by passingRate DESC var_export($NFL_Stats);

preferences:
26.78 ms | 410 KiB | 5 Q