3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = "12345"; $res = []; if (preg_match_all('~(?=((\d)\d?))~', $s, $m, PREG_SET_ORDER)) { $single = []; $double = []; foreach ($m as $v) { if ($v[1] != $v[2]) { array_push($single, $v[2]); array_push($double, $v[1]); } else { array_push($single, $v[1]); } } $res = array_merge($single, $double); print_r( $res ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 43
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 34
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 34
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 43
filename:       /in/0VfVB
function name:  (null)
number of ops:  44
compiled vars:  !0 = $s, !1 = $res, !2 = $m, !3 = $single, !4 = $double, !5 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '12345'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAL                                                 '%7E%28%3F%3D%28%28%5Cd%29%5Cd%3F%29%29%7E'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        SEND_VAL                                                 2
          7        DO_ICALL                                         $8      
          8      > JMPZ                                                     $8, ->43
    6     9    >   ASSIGN                                                   !3, <array>
         10        ASSIGN                                                   !4, <array>
    7    11      > FE_RESET_R                                       $11     !2, ->34
         12    > > FE_FETCH_R                                               $11, !5, ->34
    8    13    >   FETCH_DIM_R                                      ~12     !5, 1
         14        FETCH_DIM_R                                      ~13     !5, 2
         15        IS_NOT_EQUAL                                             ~12, ~13
         16      > JMPZ                                                     ~14, ->28
    9    17    >   INIT_FCALL                                               'array_push'
         18        SEND_REF                                                 !3
         19        FETCH_DIM_R                                      ~15     !5, 2
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                                 
   10    22        INIT_FCALL                                               'array_push'
         23        SEND_REF                                                 !4
         24        FETCH_DIM_R                                      ~17     !5, 1
         25        SEND_VAL                                                 ~17
         26        DO_ICALL                                                 
         27      > JMP                                                      ->33
   12    28    >   INIT_FCALL                                               'array_push'
         29        SEND_REF                                                 !3
         30        FETCH_DIM_R                                      ~19     !5, 1
         31        SEND_VAL                                                 ~19
         32        DO_ICALL                                                 
    7    33    > > JMP                                                      ->12
         34    >   FE_FREE                                                  $11
   15    35        INIT_FCALL                                               'array_merge'
         36        SEND_VAR                                                 !3
         37        SEND_VAR                                                 !4
         38        DO_ICALL                                         $21     
         39        ASSIGN                                                   !1, $21
   16    40        INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !1
         42        DO_ICALL                                                 
   17    43    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.19 ms | 1405 KiB | 21 Q