3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string_original = " Ivq6T2IoWbLNCoru7RTv kcEDwTVDhkqRAePOOQsM c6pcDsaq1waWzuzNHAYl pqFRFt1XwSX6JBLslwDs VWygeUir8kWMOpU5RArI WZ1UCYybMhpetyaCCkiM 8OVqENVpWmCZvDyvq8dG PPxPs48xPuiaLGdKhjEl 2i5y2URwQlRS1pbrKDS5 euT3KHvPrhM5wnOyTpJv "; var_dump($string_original); $string = $string_original; $pattern = '%' # Select a digit and 5 letters after .'(\d)(\w{5})' .'%'; $string = preg_replace_callback( $pattern, function($matches){ # Add to one to digit and then lowercase 5 letters after. $matches[1] = $matches[1] + 1; $matches[2] = strtolower($matches[2]); return $matches[1].$matches[2]; }, $string); var_dump($string); $string = $string_original; $pattern = '%' # Any digit and after 5 alpha-numeric characters. .'(\d)(?<=\w{5})' .'%'; # Replace all integers to symbols $string = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $string, # Limit only 2 replacements 2); var_dump($string); # Array Replacement $arr = [ 'IUjd5x13NF1OyQn9Afjy', 'S1BG0EhuWxr5icrgD1St', 'oLKV7cI6Qx5503K0eJ6U', 'V36IgE0TE6Qq6beBnJkC', 'jcMIKR9wk9u8kdN6UyPR', 'N8CNqZDQPJwLH87rnmKq', 'yeSAo75DcWQqQM9FynIu', 'QoRWAnP2G1LGkRoBbiud', 'tiVkR9UkIiB6ChI6l6Se', '9BWLYV7msRz7WsSADx7u' ]; $pattern = '%' # Any Digit after 10 characters .'(\d)(?<=\w{10})' .'%'; # Replace integers from <5 to _ and >5 to @ # Note the limit here works per line in the array. # And the count can be gathered via another variable declaration on the function. $arr = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $arr, 1, $count); var_dump($arr); var_dump($count);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hPl8D
function name:  (null)
number of ops:  47
compiled vars:  !0 = $string_original, !1 = $string, !2 = $pattern, !3 = $arr, !4 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0AIvq6T2IoWbLNCoru7RTv%0AkcEDwTVDhkqRAePOOQsM%0Ac6pcDsaq1waWzuzNHAYl%0ApqFRFt1XwSX6JBLslwDs%0AVWygeUir8kWMOpU5RArI%0AWZ1UCYybMhpetyaCCkiM%0A8OVqENVpWmCZvDyvq8dG%0APPxPs48xPuiaLGdKhjEl%0A2i5y2URwQlRS1pbrKDS5%0AeuT3KHvPrhM5wnOyTpJv%0A'
   15     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   17     4        ASSIGN                                                   !1, !0
   19     5        ASSIGN                                                   !2, '%25%28%5Cd%29%28%5Cw%7B5%7D%29%25'
   24     6        INIT_FCALL                                               'preg_replace_callback'
   25     7        SEND_VAR                                                 !2
   26     8        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
   31     9        SEND_VAL                                                 ~9
   32    10        SEND_VAR                                                 !1
   24    11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !1, $10
   33    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
   35    16        ASSIGN                                                   !1, !0
   36    17        ASSIGN                                                   !2, '%25%28%5Cd%29%28%3F%3C%3D%5Cw%7B5%7D%29%25'
   42    18        INIT_FCALL                                               'preg_replace_callback'
   43    19        SEND_VAR                                                 !2
   44    20        DECLARE_LAMBDA_FUNCTION                          ~15     [1]
   50    21        SEND_VAL                                                 ~15
   51    22        SEND_VAR                                                 !1
   53    23        SEND_VAL                                                 2
   42    24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !1, $16
   54    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
   57    29        ASSIGN                                                   !3, <array>
   70    30        ASSIGN                                                   !2, '%25%28%5Cd%29%28%3F%3C%3D%5Cw%7B10%7D%29%25'
   78    31        INIT_FCALL                                               'preg_replace_callback'
   79    32        SEND_VAR                                                 !2
   80    33        DECLARE_LAMBDA_FUNCTION                          ~21     [2]
   86    34        SEND_VAL                                                 ~21
   87    35        SEND_VAR                                                 !3
   88    36        SEND_VAL                                                 1
   89    37        SEND_REF                                                 !4
   78    38        DO_ICALL                                         $22     
         39        ASSIGN                                                   !3, $22
   90    40        INIT_FCALL                                               'var_dump'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
   91    43        INIT_FCALL                                               'var_dump'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
         46      > 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/hPl8D
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        FETCH_DIM_R                                      ~2      !0, 1
          2        ADD                                              ~3      ~2, 1
          3        ASSIGN_DIM                                               !0, 1
          4        OP_DATA                                                  ~3
   29     5        INIT_FCALL                                               'strtolower'
          6        FETCH_DIM_R                                      ~5      !0, 2
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        ASSIGN_DIM                                               !0, 2
         10        OP_DATA                                                  $6
   30    11        FETCH_DIM_R                                      ~7      !0, 1
         12        FETCH_DIM_R                                      ~8      !0, 2
         13        CONCAT                                           ~9      ~7, ~8
         14      > RETURN                                                   ~9
   31    15*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hPl8D
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   45     1        FETCH_DIM_R                                      ~1      !0, 1
          2        IS_SMALLER_OR_EQUAL                                      5, ~1
          3      > JMPZ                                                     ~2, ->6
   46     4    > > RETURN                                                   '_'
   45     5*       JMP                                                      ->7
   48     6    > > RETURN                                                   '%40'
   50     7*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hPl8D
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   RECV                                             !0      
   81     1        FETCH_DIM_R                                      ~1      !0, 1
          2        IS_SMALLER_OR_EQUAL                                      5, ~1
          3      > JMPZ                                                     ~2, ->6
   82     4    > > RETURN                                                   '_'
   81     5*       JMP                                                      ->7
   84     6    > > RETURN                                                   '%40'
   86     7*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.59 ms | 1470 KiB | 16 Q