3v4l.org

run code in 300+ PHP versions simultaneously
<?php $slug = '/job/hello-this-is-my-job-posting-for-a-daycare-im-looking-for-in-91770-rosemead-california-12345'; $slugLimit = 70; echo preg_replace_callback( '~^(/job/)((?:[^-]*-)*)(in-\d{5}-[^-]*-[^-]*-\d*)$~u', fn($m) => implode([ $m[1], preg_replace( '~^.{0,' . ($slugLimit - mb_strlen($m[1] . $m[3]) - 1) . '}-\K.*~u', '', $m[2] ), $m[3] ]), $slug );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/55GRn
function name:  (null)
number of ops:  11
compiled vars:  !0 = $slug, !1 = $slugLimit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Fjob%2Fhello-this-is-my-job-posting-for-a-daycare-im-looking-for-in-91770-rosemead-california-12345'
    5     1        ASSIGN                                                   !1, 70
    7     2        INIT_FCALL                                               'preg_replace_callback'
    8     3        SEND_VAL                                                 '%7E%5E%28%2Fjob%2F%29%28%28%3F%3A%5B%5E-%5D%2A-%29%2A%29%28in-%5Cd%7B5%7D-%5B%5E-%5D%2A-%5B%5E-%5D%2A-%5Cd%2A%29%24%7Eu'
    9     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   17     6        SEND_VAL                                                 ~4
   18     7        SEND_VAR                                                 !0
    7     8        DO_ICALL                                         $5      
   18     9        ECHO                                                     $5
   19    10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/55GRn
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $m, !1 = $slugLimit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'implode'
   10     3        FETCH_DIM_R                                      ~2      !0, 1
          4        INIT_ARRAY                                       ~3      ~2
   11     5        INIT_FCALL                                               'preg_replace'
   12     6        INIT_FCALL                                               'mb_strlen'
          7        FETCH_DIM_R                                      ~4      !0, 1
          8        FETCH_DIM_R                                      ~5      !0, 3
          9        CONCAT                                           ~6      ~4, ~5
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                         $7      
         12        SUB                                              ~8      !1, $7
         13        SUB                                              ~9      ~8, 1
         14        CONCAT                                           ~10     '%7E%5E.%7B0%2C', ~9
         15        CONCAT                                           ~11     ~10, '%7D-%5CK.%2A%7Eu'
         16        SEND_VAL                                                 ~11
   13    17        SEND_VAL                                                 ''
   14    18        FETCH_DIM_R                                      ~12     !0, 2
         19        SEND_VAL                                                 ~12
   11    20        DO_ICALL                                         $13     
   14    21        ADD_ARRAY_ELEMENT                                ~3      $13
   16    22        FETCH_DIM_R                                      ~14     !0, 3
         23        ADD_ARRAY_ELEMENT                                ~3      ~14
         24        SEND_VAL                                                 ~3
    9    25        DO_ICALL                                         $15     
   16    26      > RETURN                                                   $15
   17    27*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.94 ms | 1018 KiB | 17 Q