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; foreach($a as $k => $v) { // echo "Found $v at index $k\n"; if ($v == 1) { swap($a, $k, $first); } if ($v == 3) { swap($a, $k, $last); } } echo implode(" ", $a) . "\n"; function swap(&$arr, $k1, $k2) { $tmp = $arr[$k2]; $arr[$k2] = $arr[$k1]; $arr[$k1] = $tmp; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 28
Branch analysis from position: 21
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/IrbMp
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $first, !2 = $last, !3 = $v, !4 = $k
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      > FE_RESET_R                                       $12     !0, ->29
         12    > > FE_FETCH_R                                       ~13     $12, !3, ->29
         13    >   ASSIGN                                                   !4, ~13
   11    14        IS_EQUAL                                                 !3, 1
         15      > JMPZ                                                     ~15, ->21
   12    16    >   INIT_FCALL_BY_NAME                                       'swap'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAR_EX                                              !4
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
   14    21    >   IS_EQUAL                                                 !3, 3
         22      > JMPZ                                                     ~17, ->28
   15    23    >   INIT_FCALL_BY_NAME                                       'swap'
         24        SEND_VAR_EX                                              !0
         25        SEND_VAR_EX                                              !4
         26        SEND_VAR_EX                                              !2
         27        DO_FCALL                                      0          
    8    28    > > JMP                                                      ->12
         29    >   FE_FREE                                                  $12
   19    30        INIT_FCALL                                               'implode'
         31        SEND_VAL                                                 '+'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $19     
         34        CONCAT                                           ~20     $19, '%0A'
         35        ECHO                                                     ~20
   26    36      > RETURN                                                   1

Function swap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IrbMp
function name:  swap
number of ops:  11
compiled vars:  !0 = $arr, !1 = $k1, !2 = $k2, !3 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   23     3        FETCH_DIM_R                                      ~4      !0, !2
          4        ASSIGN                                                   !3, ~4
   24     5        FETCH_DIM_R                                      ~7      !0, !1
          6        ASSIGN_DIM                                               !0, !2
          7        OP_DATA                                                  ~7
   25     8        ASSIGN_DIM                                               !0, !1
          9        OP_DATA                                                  !3
   26    10      > RETURN                                                   null

End of function swap

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.1 ms | 1400 KiB | 15 Q