3v4l.org

run code in 300+ PHP versions simultaneously
<?php $aliases = [ 'foo', 'bar-1', 'joomla-23', 'joom-0', ]; foreach ($aliases as &$alias) { $alias = preg_replace_callback( '~(?:-\K\d+)?$~', function ($m) { return strlen($m[0]) ? 1 + $m[0] : '-2'; }, $alias, 1 ); } var_export($aliases);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/5IBXU
function name:  (null)
number of ops:  17
compiled vars:  !0 = $aliases, !1 = $alias
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1      > FE_RESET_RW                                      $3      !0, ->12
          2    > > FE_FETCH_RW                                              $3, !1, ->12
   11     3    >   INIT_FCALL                                               'preg_replace_callback'
   12     4        SEND_VAL                                                 '%7E%28%3F%3A-%5CK%5Cd%2B%29%3F%24%7E'
   13     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F5IBXU%3A13%240'
   15     6        SEND_VAL                                                 ~4
   16     7        SEND_VAR                                                 !1
   17     8        SEND_VAL                                                 1
          9        DO_ICALL                                         $5      
   11    10        ASSIGN                                                   !1, $5
   10    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   20    13        INIT_FCALL                                               'var_export'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F5IBXU%3A13%240:
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 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5IBXU
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_DIM_R                                      ~1      !0, 0
          2        STRLEN                                           ~2      ~1
          3      > JMPZ                                                     ~2, ->8
          4    >   FETCH_DIM_R                                      ~3      !0, 0
          5        ADD                                              ~4      1, ~3
          6        QM_ASSIGN                                        ~5      ~4
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      '-2'
          9    > > RETURN                                                   ~5
   15    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F5IBXU%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.73 ms | 1396 KiB | 17 Q