3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stats = array( array( "statname" => "foo", "totalStatPower" => 4, ), array( "statname" => "bar", "totalStatPower" => 5, ), array( "statname" => "foo", "totalStatPower" => 10, ), ); function findStatTotal($name, array $stats) { return array_reduce( array_filter( $stats, function($j) use ($name) { return $j["statname"] == $name; } ), function( $a, $b ) { return $a + $b['totalStatPower']; }, 0 ); } var_dump(findStatTotal("foo", $stats));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VmfAO
function name:  (null)
number of ops:  9
compiled vars:  !0 = $stats
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'findstattotal'
          3        SEND_VAL                                                 'foo'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function findstattotal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VmfAO
function name:  findStatTotal
number of ops:  16
compiled vars:  !0 = $name, !1 = $stats
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_FCALL                                               'array_reduce'
   20     3        INIT_FCALL                                               'array_filter'
   21     4        SEND_VAR                                                 !1
   22     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVmfAO%3A22%240'
          6        BIND_LEXICAL                                             ~2, !0
   24     7        SEND_VAL                                                 ~2
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
   26    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVmfAO%3A26%241'
   28    11        SEND_VAL                                                 ~4
   29    12        SEND_VAL                                                 0
         13        DO_ICALL                                         $5      
         14      > RETURN                                                   $5
   31    15*     > RETURN                                                   null

End of function findstattotal

Function %00%7Bclosure%7D%2Fin%2FVmfAO%3A22%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VmfAO
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $j, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   23     2        FETCH_DIM_R                                      ~2      !0, 'statname'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
   24     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVmfAO%3A22%240

Function %00%7Bclosure%7D%2Fin%2FVmfAO%3A26%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VmfAO
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        FETCH_DIM_R                                      ~2      !1, 'totalStatPower'
          3        ADD                                              ~3      !0, ~2
          4      > RETURN                                                   ~3
   28     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVmfAO%3A26%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.28 ms | 1403 KiB | 20 Q