3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "999TB2", "9999XX" ]; $re = '/^(?|(\d{3})([A-Z]{2})(\d)|(\d{2})(\d{2})([A-Z]{2}))$/'; foreach ($strings as $str) { echo preg_replace($re, '$1-$2-$3', $str) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/tXRpr
function name:  (null)
number of ops:  14
compiled vars:  !0 = $strings, !1 = $re, !2 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, '%2F%5E%28%3F%7C%28%5Cd%7B3%7D%29%28%5BA-Z%5D%7B2%7D%29%28%5Cd%29%7C%28%5Cd%7B2%7D%29%28%5Cd%7B2%7D%29%28%5BA-Z%5D%7B2%7D%29%29%24%2F'
   10     2      > FE_RESET_R                                       $5      !0, ->12
          3    > > FE_FETCH_R                                               $5, !2, ->12
   11     4    >   INIT_FCALL                                               'preg_replace'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 '%241-%242-%243'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $6      
          9        CONCAT                                           ~7      $6, '%0A'
         10        ECHO                                                     ~7
   10    11      > JMP                                                      ->3
         12    >   FE_FREE                                                  $5
   12    13      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.9 ms | 1004 KiB | 14 Q