3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(\bLAB_[0-9A-F]{2}\b)|(\bLAB_[0-9A-F]{4}\b)/'; $str = 'LAB_FF12'; preg_match($re, $str, $matches); var_dump($matches); $substitutes = ["", "DAB", "HAD"]; For($i=1; $i<count($matches); $i++){ If($matches[$i] != ""){ $result = $substitutes[$i] . substr($matches[$i],3); Break; } } Echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
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 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
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
filename:       /in/gRvHv
function name:  (null)
number of ops:  31
compiled vars:  !0 = $re, !1 = $str, !2 = $matches, !3 = $substitutes, !4 = $i, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28%5CbLAB_%5B0-9A-F%5D%7B2%7D%5Cb%29%7C%28%5CbLAB_%5B0-9A-F%5D%7B4%7D%5Cb%29%2F'
    4     1        ASSIGN                                                   !1, 'LAB_FF12'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    8     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   10    10        ASSIGN                                                   !3, <array>
   12    11        ASSIGN                                                   !4, 1
         12      > JMP                                                      ->26
   13    13    >   FETCH_DIM_R                                      ~12     !2, !4
         14        IS_NOT_EQUAL                                             ~12, ''
         15      > JMPZ                                                     ~13, ->25
   14    16    >   FETCH_DIM_R                                      ~14     !3, !4
         17        INIT_FCALL                                               'substr'
         18        FETCH_DIM_R                                      ~15     !2, !4
         19        SEND_VAL                                                 ~15
         20        SEND_VAL                                                 3
         21        DO_ICALL                                         $16     
         22        CONCAT                                           ~17     ~14, $16
         23        ASSIGN                                                   !5, ~17
   15    24      > JMP                                                      ->29
   12    25    >   PRE_INC                                                  !4
         26    >   COUNT                                            ~20     !2
         27        IS_SMALLER                                               !4, ~20
         28      > JMPNZ                                                    ~21, ->13
   19    29    >   ECHO                                                     !5
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.73 ms | 1013 KiB | 16 Q