3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strs = ['Time 24hours','Time 36hour','Time 72hr','Time 96h','Time 24hrs','Time 35h']; $rx = '~\b(?:(24|36|48|72|96)|(\d+))(h(?:(?:ou)?rs?)?)\b~'; foreach ($strs as $s) { echo preg_replace_callback($rx, function($m) { return !empty($m[1]) ? $m[1] . 'HR' : $m[2] . 'ET'; }, $s) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/ecK72
function name:  (null)
number of ops:  15
compiled vars:  !0 = $strs, !1 = $rx, !2 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, '%7E%5Cb%28%3F%3A%2824%7C36%7C48%7C72%7C96%29%7C%28%5Cd%2B%29%29%28h%28%3F%3A%28%3F%3Aou%29%3Frs%3F%29%3F%29%5Cb%7E'
    5     2      > FE_RESET_R                                           $5      !0, ->13
          3    > > FE_FETCH_R                                                   $5, !2, ->13
    6     4    >   INIT_FCALL                                                   'preg_replace_callback'
          5        SEND_VAR                                                     !1
          6        DECLARE_LAMBDA_FUNCTION                              ~6      [0]
    8     7        SEND_VAL                                                     ~6
          8        SEND_VAR                                                     !2
    6     9        DO_ICALL                                             $7      
    8    10        CONCAT                                               ~8      $7, '%0A'
         11        ECHO                                                         ~8
    5    12      > JMP                                                          ->3
         13    >   FE_FREE                                                      $5
    9    14      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ecK72
function name:  {closure:/in/ecK72:6}
number of ops:  13
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    7     1        ISSET_ISEMPTY_DIM_OBJ                             1  ~1      !0, 1
          2        BOOL_NOT                                             ~2      ~1
          3      > JMPZ                                                         ~2, ->8
          4    >   FETCH_DIM_R                                          ~3      !0, 1
          5        CONCAT                                               ~4      ~3, 'HR'
          6        QM_ASSIGN                                            ~5      ~4
          7      > JMP                                                          ->11
          8    >   FETCH_DIM_R                                          ~6      !0, 2
          9        CONCAT                                               ~7      ~6, 'ET'
         10        QM_ASSIGN                                            ~5      ~7
         11    > > RETURN                                                       ~5
    8    12*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.41 ms | 2102 KiB | 14 Q