3v4l.org

run code in 300+ PHP versions simultaneously
<?php function suma($carry, $item) { var_dump($carry); $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/ec1Oo
function name:  (null)
number of ops:  10
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                                                 
   22     9      > RETURN                                                   1

Function suma:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ec1Oo
function name:  suma
number of ops:  8
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        DO_ICALL                                                 
    6     5        ASSIGN_OP                                     1          !0, !1
    7     6      > RETURN                                                   !0
    8     7*     > 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/ec1Oo
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:
145.96 ms | 1396 KiB | 17 Q