3v4l.org

run code in 300+ PHP versions simultaneously
<?php $searchArray = array('settings all','print', 'sum', 'industry'); // total 50K words function sanitize($string,$searchArray) { $repl = array_map("dashReplace", $searchArray); $pattern = array_map("insertWordBoundaries", $searchArray); $string = preg_replace($pattern,$repl,$string); return $string; } function dashReplace($str) { return "<span class='txtOlg'>" . $str . "</span>"; } function insertWordBoundaries($str){ return "/\b". preg_quote($str,"/") ."\b/"; } $text = 'Lorem Ipsum is simply dummy text of the printing and typesettings all industry.'; echo sanitize($text,$searchArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2gved
function name:  (null)
number of ops:  8
compiled vars:  !0 = $searchArray, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, 'Lorem+Ipsum+is+simply+dummy+text+of+the+printing+and+typesettings+all+industry.'
   22     2        INIT_FCALL                                               'sanitize'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
          7      > RETURN                                                   1

Function sanitize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2gved
function name:  sanitize
number of ops:  20
compiled vars:  !0 = $string, !1 = $searchArray, !2 = $repl, !3 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'dashReplace'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
    8     7        INIT_FCALL                                               'array_map'
          8        SEND_VAL                                                 'insertWordBoundaries'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !3, $6
    9    12        INIT_FCALL                                               'preg_replace'
         13        SEND_VAR                                                 !3
         14        SEND_VAR                                                 !2
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !0, $8
   10    18      > RETURN                                                   !0
   11    19*     > RETURN                                                   null

End of function sanitize

Function dashreplace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2gved
function name:  dashReplace
number of ops:  5
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        CONCAT                                           ~1      '%3Cspan+class%3D%27txtOlg%27%3E', !0
          2        CONCAT                                           ~2      ~1, '%3C%2Fspan%3E'
          3      > RETURN                                                   ~2
   15     4*     > RETURN                                                   null

End of function dashreplace

Function insertwordboundaries:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2gved
function name:  insertWordBoundaries
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'preg_quote'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%2F'
          4        DO_ICALL                                         $1      
          5        CONCAT                                           ~2      '%2F%5Cb', $1
          6        CONCAT                                           ~3      ~2, '%5Cb%2F'
          7      > RETURN                                                   ~3
   19     8*     > RETURN                                                   null

End of function insertwordboundaries

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.94 ms | 1009 KiB | 17 Q