3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_internal_encoding('UTF-8'); $full_string = 'ĂȘtre vivant'; $match = 'vivant'; //) is ĂȘtr<strong>e viva</strong>nt echo Foo::highlightTerm($full_string, $match); class Foo{ public static function highlightTerm($full_string, $match){ $full_string_ascii = preg_replace_callback('/[\w]+/ui', array('self', 'callbackHighlightTerm'), $full_string); $match_ascii = preg_replace_callback('/[\w]+/ui', array('self', 'callbackHighlightTerm'), $match); $start = stripos($full_string_ascii, $match_ascii); if($start===FALSE){ return $full_string; }else{ $length = mb_strlen($match); /**/var_dump($full_string_ascii, $match_ascii, $start, $length); return htmlspecialchars( mb_substr($full_string, 0, $start)) . '<strong>' . htmlspecialchars( mb_substr($full_string, $start, $length) ) . '</strong>' . htmlspecialchars( mb_substr($full_string, $start+$length) ); } } private static function callbackHighlightTerm($matches){ return preg_replace('/[^\w]/i', '', iconv('UTF-8', 'ASCII//TRANSLIT', $matches[0])); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pA5Ev
function name:  (null)
number of ops:  11
compiled vars:  !0 = $full_string, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'mb_internal_encoding'
          1        SEND_VAL                                                 'UTF-8'
          2        DO_ICALL                                                 
    5     3        ASSIGN                                                   !0, '%C3%AAtre+vivant'
    6     4        ASSIGN                                                   !1, 'vivant'
    9     5        INIT_STATIC_METHOD_CALL                                  'Foo', 'highlightTerm'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $5      
          9        ECHO                                                     $5
   37    10      > RETURN                                                   1

Class Foo:
Function highlightterm:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pA5Ev
function name:  highlightTerm
number of ops:  63
compiled vars:  !0 = $full_string, !1 = $match, !2 = $full_string_ascii, !3 = $match_ascii, !4 = $start, !5 = $length
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2F%5B%5Cw%5D%2B%2Fui'
          4        SEND_VAL                                                 <array>
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   14     8        INIT_FCALL                                               'preg_replace_callback'
          9        SEND_VAL                                                 '%2F%5B%5Cw%5D%2B%2Fui'
         10        SEND_VAL                                                 <array>
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !3, $8
   16    14        INIT_FCALL                                               'stripos'
         15        SEND_VAR                                                 !2
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !4, $10
   18    19        TYPE_CHECK                                    4          !4
         20      > JMPZ                                                     ~12, ->23
   19    21    > > RETURN                                                   !0
         22*       JMP                                                      ->62
   21    23    >   INIT_FCALL                                               'mb_strlen'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $13     
         26        ASSIGN                                                   !5, $13
   22    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !2
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !4
         31        SEND_VAR                                                 !5
         32        DO_ICALL                                                 
   25    33        INIT_FCALL                                               'htmlspecialchars'
         34        INIT_FCALL                                               'mb_substr'
         35        SEND_VAR                                                 !0
         36        SEND_VAL                                                 0
         37        SEND_VAR                                                 !4
         38        DO_ICALL                                         $16     
         39        SEND_VAR                                                 $16
         40        DO_ICALL                                         $17     
   26    41        CONCAT                                           ~18     $17, '%3Cstrong%3E'
         42        INIT_FCALL                                               'htmlspecialchars'
         43        INIT_FCALL                                               'mb_substr'
         44        SEND_VAR                                                 !0
         45        SEND_VAR                                                 !4
         46        SEND_VAR                                                 !5
         47        DO_ICALL                                         $19     
         48        SEND_VAR                                                 $19
         49        DO_ICALL                                         $20     
         50        CONCAT                                           ~21     ~18, $20
         51        CONCAT                                           ~22     ~21, '%3C%2Fstrong%3E'
   27    52        INIT_FCALL                                               'htmlspecialchars'
         53        INIT_FCALL                                               'mb_substr'
         54        SEND_VAR                                                 !0
         55        ADD                                              ~23     !4, !5
         56        SEND_VAL                                                 ~23
         57        DO_ICALL                                         $24     
         58        SEND_VAR                                                 $24
         59        DO_ICALL                                         $25     
         60        CONCAT                                           ~26     ~22, $25
         61      > RETURN                                                   ~26
   29    62*     > RETURN                                                   null

End of function highlightterm

Function callbackhighlightterm:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pA5Ev
function name:  callbackHighlightTerm
number of ops:  15
compiled vars:  !0 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5B%5E%5Cw%5D%2Fi'
          3        SEND_VAL                                                 ''
          4        INIT_FCALL_BY_NAME                                       'iconv'
          5        SEND_VAL_EX                                              'UTF-8'
          6        SEND_VAL_EX                                              'ASCII%2F%2FTRANSLIT'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $1      !0, 0
          9        SEND_FUNC_ARG                                            $1
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                         $3      
         13      > RETURN                                                   $3
   34    14*     > RETURN                                                   null

End of function callbackhighlightterm

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.76 ms | 1409 KiB | 32 Q