3v4l.org

run code in 500+ 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 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/tXRpr
function name:  (null)
number of ops:  11
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, ->9
          3    > > FE_FETCH_R                                                   $5, !2, ->9
   11     4    >   FRAMELESS_ICALL_3                preg_replace        ~6      !1, '%241-%242-%243'
          5        OP_DATA                                                      !2
          6        CONCAT                                               ~7      ~6, '%0A'
          7        ECHO                                                         ~7
   10     8      > JMP                                                          ->3
          9    >   FE_FREE                                                      $5
   12    10      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.95 ms | 1856 KiB | 14 Q