3v4l.org

run code in 300+ PHP versions simultaneously
<?php define( 'ACCENT_MAP', [ "A" => "[AАĂǍĄÀÃÁÆÂÅǺĀא]", "B" => "[BБבÞ]", "C" => "[CĈĆÇЦצĊČץ]", "D" => "[DДĎĐדÐ]", "E" => "[EÈĘÉËÊЕĒĖĚĔЄƏע]", "F" => "[FФƑ]", "G" => "[GĞĠĢĜГגҐ]", "H" => "[HחĦХĤה]", "I" => "[IIÏÎÍÌĮĬIИĨǏיЇĪІ]", "J" => "[JЙĴ]", "K" => "[KĸכĶКך]", "L" => "[LŁĿЛĻĹĽל]", "M" => "[MמМם]", "N" => "[NÑŃНŅןŊנʼnŇ]", "O" => "[OØÓÒÔÕОŐŎŌǾǑƠ]", "P" => "[PפףП]", "Q" => "[Qק]", "R" => "[RŔŘŖרР]", "S" => "[SŞŚȘŠСŜס]", "T" => "[TТȚטŦתŤŢ]", "U" => "[UÙÛÚŪУŨƯǓŲŬŮŰǕǛǙǗ]", "V" => "[VВו]", "Y" => "[YÝЫŶŸ]", "Z" => "(?:Z|ŹŽŻЗז", "a" => "[aаăǎąàãáæâåǻāא]", "b" => "[bбבþ]", "c" => "[cĉćçцצċčץ]", "ch" => "(?:ch|ч)", "d" => "[dдďđדð]", "e" => "[eèęéëêеēėěĕєəע]", "f" => "[fфƒ]", "g" => "[gğġģĝгגґ]", "h" => "[hחħхĥה]", "i" => "[iiïîíìįĭıиĩǐיїīі]", "j" => "[jйĵ]", "k" => "[kĸכķкך]", "l" => "[lłŀлļĺľל]", "m" => "[mמмם]", "n" => "[nñńнņןŋנʼnň]", "o" => "[oøóòôõоőŏōǿǒơ]", "p" => "[pפףп]", "q" => "[qק]", "r" => "[rŕřŗרр]", "s" => "[sşśșšсŝס]", "t" => "[tтțטŧתťţ]", "u" => "[uùûúūуũưǔųŭůűǖǜǚǘ]", "v" => "[vвו]", "y" => "[yýыŷÿ]", "z" => "[zźžżзזſ]", "ae" => "(?:ae|[ÄǼäæǽ])", "ch" => "(?:ch|[Чч])", "ij" => "(?:ij|[ijIJ])", "ja" => "(?:ja|[яЯ])", "je" => "(?:je|[Ээ])", "jo" => "(?:jo|[ёЁ])", "ju" => "(?:ju|[юЮ])", "oe" => "(?:oe|[œŒöÖ])", "sch" => "(?:sch|[щЩ])", "sh" => "(?:sh|[шШ])", "ss" => "(?:ss|[ß])", "ue" => "(?:ue|[Ü)", "zh" => "(?:zh|[Жж])" ]); function highlightTerm($text, $keyword) { $regex = implode( '|', array_map( fn($w) => strtr(preg_quote($w), ACCENT_MAP), explode(" ", $keyword) ) ); return preg_replace( "#$regex#ui", '<span style="background:yellow;">$0</span>', $text ); } echo highlightTerm("Would you like a café, Mister Kàpêk?", "kape caf");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KFra1
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
    4     1        SEND_VAL                                                 'ACCENT_MAP'
    6     2        SEND_VAL                                                 <array>
    3     3        DO_ICALL                                                 
   85     4        INIT_FCALL                                               'highlightterm'
          5        SEND_VAL                                                 'Would+you+like+a+caf%C3%A9%2C+Mister+K%C3%A0p%C3%AAk%3F'
          6        SEND_VAL                                                 'kape+caf'
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9      > RETURN                                                   1

Function highlightterm:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KFra1
function name:  highlightTerm
number of ops:  26
compiled vars:  !0 = $text, !1 = $keyword, !2 = $regex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   71     2        INIT_FCALL                                               'implode'
   72     3        SEND_VAL                                                 '%7C'
   73     4        INIT_FCALL                                               'array_map'
   74     5        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          6        SEND_VAL                                                 ~3
   75     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '+'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
   73    12        DO_ICALL                                         $5      
   75    13        SEND_VAR                                                 $5
   71    14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !2, $6
   78    16        INIT_FCALL                                               'preg_replace'
   79    17        ROPE_INIT                                     3  ~9      '%23'
         18        ROPE_ADD                                      1  ~9      ~9, !2
         19        ROPE_END                                      2  ~8      ~9, '%23ui'
         20        SEND_VAL                                                 ~8
   80    21        SEND_VAL                                                 '%3Cspan+style%3D%22background%3Ayellow%3B%22%3E%240%3C%2Fspan%3E'
   81    22        SEND_VAR                                                 !0
   78    23        DO_ICALL                                         $11     
   81    24      > RETURN                                                   $11
   83    25*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KFra1
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'strtr'
          2        INIT_FCALL                                               'preg_quote'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        FETCH_CONSTANT                                   ~2      'ACCENT_MAP'
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                         $3      
          9      > RETURN                                                   $3
         10*     > RETURN                                                   null

End of Dynamic Function 0

End of function highlightterm

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.34 ms | 1014 KiB | 21 Q