3v4l.org

run code in 300+ PHP versions simultaneously
<?php $message = 'This is a string using the terms? Wait here\'s one abukuma kai abukuma-kai abukuma abukuma'; $search = array( 'abukuma kai', 'abukuma' ); $replacements = array( // here all replaces | each in a new line - watch the syntax // all html possible, but no single quotation mark! '<a href="http://kancolle.wikia.com/wiki/Abukuma#Upgrade" class="screenshot" rel="ship/Abukuma_Kai.png" style="color:#0073e6; font-weight:bold; border-bottom: 1px #0073e6 dashed;"><p id="yosup">Abukuma Kai</p></a>', '<a href="http://kancolle.wikia.com/wiki/Abukuma#Basic" class="screenshot" rel="ship/Abukuma.png" style="color:#0073e6; font-weight:bold; border-bottom: 1px #0073e6 dashed;">Abukuma</a>' ); // Massage the message $message = preg_replace( array_map( function($s) { $s = preg_quote($s); $s = str_replace(' ', '[ -_]', $s); return '/' . $s . '/'; }, $search ), array_map( function ($s) { return '%%' . $s . '%%'; }, array_keys($search) ), $message ); $message = str_replace( array_map( function($s) { return '%%' . $s . '%%'; }, array_keys($replacements) ), $replacements, $message );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljFfP
function name:  (null)
number of ops:  37
compiled vars:  !0 = $message, !1 = $search, !2 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'This+is+a+string+using+the+terms%3F++Wait+here%27s+one+abukuma+kai+abukuma-kai+abukuma+abukuma'
    5     1        ASSIGN                                                   !1, <array>
   11     2        ASSIGN                                                   !2, <array>
   19     3        INIT_FCALL                                               'preg_replace'
   20     4        INIT_FCALL                                               'array_map'
   21     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FljFfP%3A21%240'
   26     6        SEND_VAL                                                 ~6
   27     7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
   29    10        INIT_FCALL                                               'array_map'
   30    11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FljFfP%3A30%241'
         12        SEND_VAL                                                 ~8
   31    13        INIT_FCALL                                               'array_keys'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $9      
         16        SEND_VAR                                                 $9
         17        DO_ICALL                                         $10     
         18        SEND_VAR                                                 $10
   33    19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $11     
   19    21        ASSIGN                                                   !0, $11
   37    22        INIT_FCALL                                               'str_replace'
   38    23        INIT_FCALL                                               'array_map'
   39    24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FljFfP%3A39%242'
         25        SEND_VAL                                                 ~13
   40    26        INIT_FCALL                                               'array_keys'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $14     
         29        SEND_VAR                                                 $14
         30        DO_ICALL                                         $15     
         31        SEND_VAR                                                 $15
   42    32        SEND_VAR                                                 !2
   43    33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $16     
   37    35        ASSIGN                                                   !0, $16
   44    36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FljFfP%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljFfP
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   23     5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '+'
          7        SEND_VAL                                                 '%5B+-_%5D'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $3      
         10        ASSIGN                                                   !0, $3
   25    11        CONCAT                                           ~5      '%2F', !0
         12        CONCAT                                           ~6      ~5, '%2F'
         13      > RETURN                                                   ~6
   26    14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FljFfP%3A21%240

Function %00%7Bclosure%7D%2Fin%2FljFfP%3A30%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljFfP
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      '%25%25', !0
          2        CONCAT                                           ~2      ~1, '%25%25'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FljFfP%3A30%241

Function %00%7Bclosure%7D%2Fin%2FljFfP%3A39%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ljFfP
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      '%25%25', !0
          2        CONCAT                                           ~2      ~1, '%25%25'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FljFfP%3A39%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.47 ms | 1400 KiB | 23 Q