3v4l.org

run code in 300+ PHP versions simultaneously
<?php function suma($carry, $item) { var_dump($carry, $item); $carry += $item; return $carry; } function producto($carry, $item) { $carry *= $item; return $carry; } $a = array(1, 2, 3, 4, 5); $x = array(); var_dump(array_reduce($a, "suma")); // int(15) var_dump(array_reduce($a, "producto", 10)); // int(1200), ya que: 10*1*2*3*4*5 var_dump(array_reduce($x, "suma", "No hay datos a reducir")); // string(22) "No hay datos a reducir" ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5VJ2
function name:  (null)
number of ops:  26
compiled vars:  !0 = $a, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'array_reduce'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'suma'
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   20     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'array_reduce'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 'producto'
         13        SEND_VAL                                                 10
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   21    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'array_reduce'
         19        SEND_VAR                                                 !1
         20        SEND_VAL                                                 'suma'
         21        SEND_VAL                                                 'No+hay+datos+a+reducir'
         22        DO_ICALL                                         $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                                 
   22    25      > RETURN                                                   1

Function suma:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5VJ2
function name:  suma
number of ops:  9
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
    6     6        ASSIGN_OP                                     1          !0, !1
    7     7      > RETURN                                                   !0
    8     8*     > RETURN                                                   null

End of function suma

Function producto:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U5VJ2
function name:  producto
number of ops:  5
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN_OP                                     3          !0, !1
   13     3      > RETURN                                                   !0
   14     4*     > RETURN                                                   null

End of function producto

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
10.89 ms | 412 KiB | 7 Q