3v4l.org

run code in 300+ PHP versions simultaneously
<?php $message = 'choukai kai hey this matches too 423-2123'; $search = array('surfing', 'joke and stuff', 'smile and etc', '3-2', 'choukai kai', 'choukai'); // Massage the message $message = preg_replace( '/(' . implode('|', array_map('preg_quote', $search)) . ')/i', '%%$1%%', $message ); $replacements = array( // here all replaces | each in a new line - watch the syntax // all html possible, but no single quotation mark! '<a href="http://en.wikipedia.org/wiki/Surfing" style="color:darkred;font-weight:bold;">surfing</a>', '<a href="http://en.wikipedia.org/wiki/Joke" style="color:darkred;font-weight:bold;">joke</a>', '<a href="http://en.wikipedia.org/wiki/Smiling" style="color:darkred;font-weight:bold;">Smile</a>', '<a class="screenshot" rel="3-2_Map.jpg">3-2</a>', '<a href="http://en.wikipedia.org/wiki/Joke" style="color:darkred;font-weight:bold;">Choukai Kai</a>', '<a href="http://en.wikipedia.org/wiki/Smiling" style="color:darkred;font-weight:bold;">Choukai</a>' ); $message = str_replace( array_map(function($s) { return '%%' . $s . '%%'; }, $search), $replacements, $message ); var_dump($message);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/poUuo
function name:  (null)
number of ops:  34
compiled vars:  !0 = $message, !1 = $search, !2 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'choukai+kai+hey+this+matches+too+423-2123'
    5     1        ASSIGN                                                   !1, <array>
    8     2        INIT_FCALL                                               'preg_replace'
    9     3        INIT_FCALL                                               'implode'
          4        SEND_VAL                                                 '%7C'
          5        INIT_FCALL                                               'array_map'
          6        SEND_VAL                                                 'preg_quote'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                         $6      
         11        CONCAT                                           ~7      '%2F%28', $6
         12        CONCAT                                           ~8      ~7, '%29%2Fi'
         13        SEND_VAL                                                 ~8
   10    14        SEND_VAL                                                 '%25%25%241%25%25'
   11    15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $9      
    8    17        ASSIGN                                                   !0, $9
   14    18        ASSIGN                                                   !2, <array>
   25    19        INIT_FCALL                                               'str_replace'
   26    20        INIT_FCALL                                               'array_map'
         21        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpoUuo%3A26%240'
         22        SEND_VAL                                                 ~12
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $13     
         25        SEND_VAR                                                 $13
   27    26        SEND_VAR                                                 !2
   28    27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $14     
   25    29        ASSIGN                                                   !0, $14
   31    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FpoUuo%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/poUuo
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     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%2FpoUuo%3A26%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.05 ms | 1400 KiB | 23 Q