3v4l.org

run code in 500+ 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:  20
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      
   73     2        INIT_FCALL                                                   'array_map'
   74     3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          4        SEND_VAL                                                     ~3
   75     5        INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '+'
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                             $4      
          9        SEND_VAR                                                     $4
   73    10        DO_ICALL                                             $5      
   71    11        FRAMELESS_ICALL_2                implode             ~6      '%7C', $5
         12        ASSIGN                                                       !2, ~6
   79    13        ROPE_INIT                                         3  ~9      '%23'
         14        ROPE_ADD                                          1  ~9      ~9, !2
         15        ROPE_END                                          2  ~8      ~9, '%23ui'
   78    16        FRAMELESS_ICALL_3                preg_replace        ~11     ~8, '%3Cspan+style%3D%22background%3Ayellow%3B%22%3E%240%3C%2Fspan%3E'
   81    17        OP_DATA                                                      !0
         18      > RETURN                                                       ~11
   83    19*     > 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:highlightTerm():74}
number of ops:  8
compiled vars:  !0 = $w
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   74     0  E >   RECV                                                 !0      
          1        INIT_FCALL                                                   'preg_quote'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        FETCH_CONSTANT                                       ~2      'ACCENT_MAP'
          5        FRAMELESS_ICALL_2                strtr               ~3      $1, ~2
          6      > RETURN                                                       ~3
          7*     > RETURN                                                       null

End of Dynamic Function 0

End of function highlightterm

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.18 ms | 1892 KiB | 25 Q