3v4l.org

run code in 500+ PHP versions simultaneously
<?php $init1 = [[1,1]]; $init2 = [[5,2]]; function addMovement($array) { $lastPos = end($array); $array[] = [$lastPos[0]+1, $lastPos[1]+2]; return $array; } $array = $init1; for ($i = 0; $i < 3; $i++) { $array = addMovement($array); } $array = array_merge($array, $init2); for ($i = 0; $i < 2; $i++) { $array = addMovement($array); } print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 19
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 19
Branch analysis from position: 26
Branch analysis from position: 19
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 5
Branch analysis from position: 12
Branch analysis from position: 5
filename:       /in/J6uEa
function name:  (null)
number of ops:  30
compiled vars:  !0 = $init1, !1 = $init2, !2 = $array, !3 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
   12     2        ASSIGN                                                       !2, !0
   13     3        ASSIGN                                                       !3, 0
          4      > JMP                                                          ->10
   15     5    >   INIT_FCALL                                                   'addmovement'
          6        SEND_VAR                                                     !2
          7        DO_FCALL                                          0  $8      
          8        ASSIGN                                                       !2, $8
   13     9        PRE_INC                                                      !3
         10    >   IS_SMALLER                                                   !3, 3
         11      > JMPNZ                                                        ~11, ->5
   17    12    >   INIT_FCALL                                                   'array_merge'
         13        SEND_VAR                                                     !2
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                             $12     
         16        ASSIGN                                                       !2, $12
   18    17        ASSIGN                                                       !3, 0
         18      > JMP                                                          ->24
   20    19    >   INIT_FCALL                                                   'addmovement'
         20        SEND_VAR                                                     !2
         21        DO_FCALL                                          0  $15     
         22        ASSIGN                                                       !2, $15
   18    23        PRE_INC                                                      !3
         24    >   IS_SMALLER                                                   !3, 2
         25      > JMPNZ                                                        ~18, ->19
   22    26    >   INIT_FCALL                                                   'print_r'
         27        SEND_VAR                                                     !2
         28        DO_ICALL                                                     
         29      > RETURN                                                       1

Function addmovement:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J6uEa
function name:  addMovement
number of ops:  15
compiled vars:  !0 = $array, !1 = $lastPos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    8     1        INIT_FCALL                                                   'end'
          2        SEND_REF                                                     !0
          3        DO_ICALL                                             $2      
          4        ASSIGN                                                       !1, $2
    9     5        FETCH_DIM_R                                          ~5      !1, 0
          6        ADD                                                  ~6      ~5, 1
          7        INIT_ARRAY                                           ~7      ~6
          8        FETCH_DIM_R                                          ~8      !1, 1
          9        ADD                                                  ~9      ~8, 2
         10        ADD_ARRAY_ELEMENT                                    ~7      ~9
         11        ASSIGN_DIM                                                   !0
         12        OP_DATA                                                      ~7
   10    13      > RETURN                                                       !0
   11    14*     > RETURN                                                       null

End of function addmovement

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
227.79 ms | 2789 KiB | 18 Q