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); echo $last; for($i = $first; $i += 1; $i < $last) { echo $i . "\n"; //$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 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
Branch analysis from position: 13
Branch analysis from position: 19
Branch analysis from position: 17
filename:       /in/leMME
function name:  (null)
number of ops:  30
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        ASSIGN                                                   !2, ~9
    8    10        ECHO                                                     !2
   10    11        ASSIGN                                                   !3, !1
         12      > JMP                                                      ->21
   12    13    >   CONCAT                                           ~12     !3, '%0A'
         14        ECHO                                                     ~12
   16    15        IS_EQUAL                                                 !4, 1
         16      > JMPZ                                                     ~13, ->17
   19    17    >   IS_EQUAL                                                 !4, 3
         18      > JMPZ                                                     ~14, ->19
   10    19    >   IS_SMALLER                                       ~15     !3, !2
         20        FREE                                                     ~15
         21    >   ASSIGN_OP                                     1  ~16     !3, 1
         22      > JMPNZ                                                    ~16, ->13
   24    23    >   INIT_FCALL                                               'implode'
         24        SEND_VAL                                                 '+'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $17     
         27        CONCAT                                           ~18     $17, '%0A'
         28        ECHO                                                     ~18
   32    29      > RETURN                                                   1

Function swap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/leMME
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
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   28     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
   29     9        FETCH_DIM_R                                      ~8      !0, !2
         10        ASSIGN                                                   !3, ~8
   30    11        FETCH_DIM_R                                      ~11     !0, !1
         12        ASSIGN_DIM                                               !0, !2
         13        OP_DATA                                                  ~11
   31    14        ASSIGN_DIM                                               !0, !1
         15        OP_DATA                                                  !3
   32    16      > RETURN                                                   null

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.68 ms | 1400 KiB | 15 Q