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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 39
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 39
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/9ULHr
function name:  (null)
number of ops:  49
compiled vars:  !0 = $csv, !1 = $line, !2 = $name, !3 = $team, !4 = $completions, !5 = $attempts, !6 = $yards, !7 = $touchdowns, !8 = $interceptions, !9 = $NFL_Stats
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'Tom+Brady%2CNE%2C385%2C581%2C4577%2C32%2C8%0APhilip+Rivers%2CLAC%2C360%2C575%2C4515%2C28%2C10%0AMatthew+Stafford%2CDET%2C371%2C565%2C4446%2C29%2C10%0ADrew+Brees%2CNO%2C386%2C536%2C4334%2C23%2C8%0ABen+Roethlisberger%2CPIT%2C360%2C561%2C4251%2C28%2C14%0AMatt+Ryan%2CATL%2C342%2C529%2C4095%2C20%2C12%0AKirk+Cousins%2CWAS%2C347%2C540%2C4093%2C27%2C13%0AAlex+Smith%2CKC%2C341%2C505%2C4042%2C26%2C5%0ARussell+Wilson%2CSEA%2C339%2C553%2C3983%2C34%2C11%0AJared+Goff%2CLA%2C296%2C477%2C3804%2C28%2C7%0ABlake+Bortles%2CJAX%2C315%2C523%2C3687%2C21%2C13%0ACase+Keenum%2CMIN%2C325%2C481%2C3547%2C22%2C7%0AJameis+Winston%2CTB%2C282%2C442%2C3504%2C19%2C11%0ADerek+Carr%2COAK%2C323%2C515%2C3496%2C22%2C13%0AEli+Manning%2CNYG%2C352%2C571%2C3468%2C19%2C13%0ADak+Prescott%2CDAL%2C308%2C490%2C3324%2C22%2C13%0AAndy+Dalton%2CCIN%2C297%2C496%2C3320%2C25%2C12%0ACam+Newton%2CCAR%2C291%2C492%2C3302%2C22%2C16%0ACarson+Wentz%2CPHI%2C265%2C440%2C3296%2C33%2C7%0AMarcus+Mariota%2CTEN%2C281%2C453%2C3232%2C13%2C15%0AJoe+Flacco%2CBAL%2C352%2C549%2C3141%2C18%2C13%0AJacoby+Brissett%2CIND%2C276%2C469%2C3098%2C13%2C7%0AJosh+McCown%2CNYJ%2C267%2C397%2C2926%2C18%2C9'
   38     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $11     
          5      > FE_RESET_R                                       $12     $11, ->39
          6    > > FE_FETCH_R                                               $12, !1, ->39
   39     7    >   INIT_FCALL                                               'str_getcsv'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 '%2C'
         10        DO_ICALL                                         $13     
         11        FETCH_LIST_R                                     $14     $13, 0
         12        ASSIGN                                                   !2, $14
         13        FETCH_LIST_R                                     $16     $13, 1
         14        ASSIGN                                                   !3, $16
         15        FETCH_LIST_R                                     $18     $13, 2
         16        ASSIGN                                                   !4, $18
         17        FETCH_LIST_R                                     $20     $13, 3
         18        ASSIGN                                                   !5, $20
         19        FETCH_LIST_R                                     $22     $13, 4
         20        ASSIGN                                                   !6, $22
         21        FETCH_LIST_R                                     $24     $13, 5
         22        ASSIGN                                                   !7, $24
         23        FETCH_LIST_R                                     $26     $13, 6
         24        ASSIGN                                                   !8, $26
         25        FREE                                                     $13
   40    26        INIT_ARRAY                                       ~29     !3, 'team'
         27        ADD_ARRAY_ELEMENT                                ~29     !2, 'name'
         28        INIT_FCALL                                               'calculate'
         29        SEND_VAR                                                 !4
         30        SEND_VAR                                                 !5
         31        SEND_VAR                                                 !6
         32        SEND_VAR                                                 !7
         33        SEND_VAR                                                 !8
         34        DO_FCALL                                      0  $30     
         35        ADD_ARRAY_ELEMENT                                ~29     $30, 'passingRate'
         36        ASSIGN_DIM                                               !9
         37        OP_DATA                                                  ~29
   38    38      > JMP                                                      ->6
         39    >   FE_FREE                                                  $12
   42    40        INIT_FCALL                                               'usort'
         41        SEND_REF                                                 !9
         42        DECLARE_LAMBDA_FUNCTION                          ~31     [0]
         43        SEND_VAL                                                 ~31
         44        DO_ICALL                                                 
   43    45        INIT_FCALL                                               'var_export'
         46        SEND_VAR                                                 !9
         47        DO_ICALL                                                 
         48      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ULHr
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !1, 'passingRate'
          3        FETCH_DIM_R                                      ~3      !0, 'passingRate'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

Function calculate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9ULHr
function name:  Calculate
number of ops:  48
compiled vars:  !0 = $completions, !1 = $attempts, !2 = $yards, !3 = $touchdowns, !4 = $interceptions, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   30     5        INIT_FCALL                                               'min'
          6        SEND_VAL                                                 2.375
          7        DIV                                              ~6      !0, !1
          8        SUB                                              ~7      ~6, 0.3
          9        MUL                                              ~8      ~7, 5
         10        SEND_VAL                                                 ~8
         11        DO_ICALL                                         $9      
         12        INIT_ARRAY                                       ~10     $9
   31    13        INIT_FCALL                                               'min'
         14        SEND_VAL                                                 2.375
         15        DIV                                              ~11     !2, !1
         16        SUB                                              ~12     ~11, 3
         17        MUL                                              ~13     ~12, 0.25
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $14     
         20        ADD_ARRAY_ELEMENT                                ~10     $14
   32    21        INIT_FCALL                                               'min'
         22        SEND_VAL                                                 2.375
         23        DIV                                              ~15     !3, !1
         24        MUL                                              ~16     ~15, 20
         25        SEND_VAL                                                 ~16
         26        DO_ICALL                                         $17     
         27        ADD_ARRAY_ELEMENT                                ~10     $17
   33    28        INIT_FCALL                                               'min'
         29        SEND_VAL                                                 2.375
         30        DIV                                              ~18     !4, !1
         31        MUL                                              ~19     ~18, 25
         32        SUB                                              ~20     2.375, ~19
         33        SEND_VAL                                                 ~20
         34        DO_ICALL                                         $21     
         35        ADD_ARRAY_ELEMENT                                ~10     $21
   29    36        ASSIGN                                                   !5, ~10
   35    37        INIT_FCALL                                               'round'
         38        INIT_FCALL                                               'array_sum'
         39        SEND_VAR                                                 !5
         40        DO_ICALL                                         $23     
         41        DIV                                              ~24     $23, 6
         42        MUL                                              ~25     ~24, 100
         43        SEND_VAL                                                 ~25
         44        SEND_VAL                                                 2
         45        DO_ICALL                                         $26     
         46      > RETURN                                                   $26
   36    47*     > RETURN                                                   null

End of function calculate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.58 ms | 1018 KiB | 21 Q