3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = [1, 2, 3, 4, 5, 6]; $result = 0; reset($values); while (key($values) !== null) { $result += current($values) - next($values); next($values); } var_dump($result); var_dump(array_sum(array_column(array_chunk($values, 2), 0)) - array_sum(array_column(array_chunk($values, 2), 1))); var_dump( array_reduce(array_chunk($values, 2), function ($result, $item) { return $result + current($item) - next($item); }));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 6
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 6
Branch analysis from position: 22
Branch analysis from position: 6
filename:       /in/7kbUV
function name:  (null)
number of ops:  64
compiled vars:  !0 = $values, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, 0
    7     2        INIT_FCALL                                               'reset'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                                 
    8     5      > JMP                                                      ->17
   10     6    >   INIT_FCALL                                               'current'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        INIT_FCALL                                               'next'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                         $6      
         12        SUB                                              ~7      $5, $6
         13        ASSIGN_OP                                     1          !1, ~7
   11    14        INIT_FCALL                                               'next'
         15        SEND_REF                                                 !0
         16        DO_ICALL                                                 
    8    17    >   INIT_FCALL                                               'key'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $10     
         20        TYPE_CHECK                                  1020          $10
         21      > JMPNZ                                                    ~11, ->6
   13    22    >   INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   16    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'array_sum'
         27        INIT_FCALL                                               'array_column'
         28        INIT_FCALL                                               'array_chunk'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 2
         31        DO_ICALL                                         $13     
         32        SEND_VAR                                                 $13
         33        SEND_VAL                                                 0
         34        DO_ICALL                                         $14     
         35        SEND_VAR                                                 $14
         36        DO_ICALL                                         $15     
         37        INIT_FCALL                                               'array_sum'
         38        INIT_FCALL                                               'array_column'
         39        INIT_FCALL                                               'array_chunk'
         40        SEND_VAR                                                 !0
         41        SEND_VAL                                                 2
         42        DO_ICALL                                         $16     
         43        SEND_VAR                                                 $16
         44        SEND_VAL                                                 1
         45        DO_ICALL                                         $17     
         46        SEND_VAR                                                 $17
         47        DO_ICALL                                         $18     
         48        SUB                                              ~19     $15, $18
         49        SEND_VAL                                                 ~19
         50        DO_ICALL                                                 
   18    51        INIT_FCALL                                               'var_dump'
   19    52        INIT_FCALL                                               'array_reduce'
         53        INIT_FCALL                                               'array_chunk'
         54        SEND_VAR                                                 !0
         55        SEND_VAL                                                 2
         56        DO_ICALL                                         $21     
         57        SEND_VAR                                                 $21
         58        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7kbUV%3A19%240'
   22    59        SEND_VAL                                                 ~22
         60        DO_ICALL                                         $23     
         61        SEND_VAR                                                 $23
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7kbUV%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7kbUV
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $result, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        INIT_FCALL                                               'current'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $2      
          5        ADD                                              ~3      !0, $2
          6        INIT_FCALL                                               'next'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $4      
          9        SUB                                              ~5      ~3, $4
         10      > RETURN                                                   ~5
   22    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7kbUV%3A19%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.6 ms | 1404 KiB | 31 Q