3v4l.org

run code in 300+ PHP versions simultaneously
<?php function suma($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/R9Zvs
function name:  (null)
number of ops:  26
compiled vars:  !0 = $a, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   18     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                                                 
   19     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                                                 
   20    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                                                 
   21    25      > RETURN                                                   1

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

End of function producto

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.45 ms | 1011 KiB | 15 Q