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($k, $first); } if ($v == 3) { swap($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 = 27
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 26
Branch analysis from position: 20
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/gpGeu
function name:  (null)
number of ops:  35
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, ->27
         12    > > FE_FETCH_R                                       ~13     $12, !3, ->27
         13    >   ASSIGN                                                   !4, ~13
   11    14        IS_EQUAL                                                 !3, 1
         15      > JMPZ                                                     ~15, ->20
   12    16    >   INIT_FCALL_BY_NAME                                       'swap'
         17        SEND_VAR_EX                                              !4
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0          
   14    20    >   IS_EQUAL                                                 !3, 3
         21      > JMPZ                                                     ~17, ->26
   15    22    >   INIT_FCALL_BY_NAME                                       'swap'
         23        SEND_VAR_EX                                              !4
         24        SEND_VAR_EX                                              !2
         25        DO_FCALL                                      0          
    8    26    > > JMP                                                      ->12
         27    >   FE_FREE                                                  $12
   19    28        INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '+'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $19     
         32        CONCAT                                           ~20     $19, '%0A'
         33        ECHO                                                     ~20
   26    34      > RETURN                                                   1

Function swap:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gpGeu
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:
154.56 ms | 1400 KiB | 15 Q