3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(1,2,1,3,2,1,3,2,1,3,2,1,2,3,1,2,3); echo implode(" ", $a) . "\n"; $first = 0; $last = sizeof($a) - 1; for($i = $first; $i += 1; $i <= $last) { $v = $a[$i]; echo "Found $v at index $i\n"; if ($v == 1) { // swap($a, $i, $first); } if ($v == 3) { // swap($a, $i, $last); } } echo implode(" ", $a) . "\n"; function swap(&$arr, $k1, $k2) { echo "Swapping $k1 and $k2\n"; $tmp = $arr[$k2]; $arr[$k2] = $arr[$k1]; $arr[$k1] = $tmp; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 13
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 13
Branch analysis from position: 29
Branch analysis from position: 13
Branch analysis from position: 25
Branch analysis from position: 23
filename:       /in/8UtIN
function name:  (null)
number of ops:  36
compiled vars:  !0 = $a, !1 = $first, !2 = $last, !3 = $i, !4 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        CONCAT                                           ~7      $6, '%0A'
          6        ECHO                                                     ~7
    6     7        ASSIGN                                                   !1, 0
    7     8        COUNT                                            ~9      !0
          9        SUB                                              ~10     ~9, 1
         10        ASSIGN                                                   !2, ~10
    8    11        ASSIGN                                                   !3, !1
         12      > JMP                                                      ->27
   10    13    >   FETCH_DIM_R                                      ~13     !0, !3
         14        ASSIGN                                                   !4, ~13
   11    15        ROPE_INIT                                     5  ~16     'Found+'
         16        ROPE_ADD                                      1  ~16     ~16, !4
         17        ROPE_ADD                                      2  ~16     ~16, '+at+index+'
         18        ROPE_ADD                                      3  ~16     ~16, !3
         19        ROPE_END                                      4  ~15     ~16, '%0A'
         20        ECHO                                                     ~15
   13    21        IS_EQUAL                                                 !4, 1
         22      > JMPZ                                                     ~19, ->23
   16    23    >   IS_EQUAL                                                 !4, 3
         24      > JMPZ                                                     ~20, ->25
    8    25    >   IS_SMALLER_OR_EQUAL                              ~21     !3, !2
         26        FREE                                                     ~21
         27    >   ASSIGN_OP                                     1  ~22     !3, 1
         28      > JMPNZ                                                    ~22, ->13
   21    29    >   INIT_FCALL                                               'implode'
         30        SEND_VAL                                                 '+'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $23     
         33        CONCAT                                           ~24     $23, '%0A'
         34        ECHO                                                     ~24
   29    35      > RETURN                                                   1

Function swap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8UtIN
function name:  swap
number of ops:  17
compiled vars:  !0 = $arr, !1 = $k1, !2 = $k2, !3 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   25     3        ROPE_INIT                                     5  ~5      'Swapping+'
          4        ROPE_ADD                                      1  ~5      ~5, !1
          5        ROPE_ADD                                      2  ~5      ~5, '+and+'
          6        ROPE_ADD                                      3  ~5      ~5, !2
          7        ROPE_END                                      4  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   26     9        FETCH_DIM_R                                      ~8      !0, !2
         10        ASSIGN                                                   !3, ~8
   27    11        FETCH_DIM_R                                      ~11     !0, !1
         12        ASSIGN_DIM                                               !0, !2
         13        OP_DATA                                                  ~11
   28    14        ASSIGN_DIM                                               !0, !1
         15        OP_DATA                                                  !3
   29    16      > RETURN                                                   null

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.49 ms | 1400 KiB | 15 Q