3v4l.org

run code in 300+ PHP versions simultaneously
<?php $title = "服务员服务员服务服务员服务员"; $term = "服务,服务员"; $termKey = explode(',' , $term); $tempTitle = ''; $strlength = strlen($title); if($title && !empty($termKey) && is_array($termKey)){ $newTitle = $title; $cur = count($termKey) - 1; //倒叙匹配 for($i=$cur;$i >= 0 ;--$i) { if($termKey[$i] && strstr($newTitle , $termKey[$i])) { $position = mb_strrpos($newTitle,'</span>'); if($position){ $tempTitle .= mb_substr($newTitle , 0 , $position , 'UTF-8'); } $str = '<span class="fc-red">'.$termKey[$i].'</span>'; $jieduan=mb_substr($newTitle , $position , $strlength , 'UTF-8'); echo '---'.$jieduan.'----'; $newTitle = preg_replace("/$termKey[$i]/i" , $str , $jieduan ,1); } } $newTitle = $tempTitle.$newTitle; //echo $newTitle; }else echo $title;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 77
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 24
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 71
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 46
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 24
Branch analysis from position: 74
Branch analysis from position: 24
Branch analysis from position: 46
Branch analysis from position: 71
Branch analysis from position: 32
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 14
filename:       /in/oV0CE
function name:  (null)
number of ops:  79
compiled vars:  !0 = $title, !1 = $term, !2 = $termKey, !3 = $tempTitle, !4 = $strlength, !5 = $newTitle, !6 = $cur, !7 = $i, !8 = $position, !9 = $str, !10 = $jieduan
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%E6%9C%8D%E5%8A%A1%E5%91%98%E6%9C%8D%E5%8A%A1%E5%91%98%E6%9C%8D%E5%8A%A1%E6%9C%8D%E5%8A%A1%E5%91%98%E6%9C%8D%E5%8A%A1%E5%91%98'
    3     1        ASSIGN                                                   !1, '%E6%9C%8D%E5%8A%A1%2C%E6%9C%8D%E5%8A%A1%E5%91%98'
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2C'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $13     
          6        ASSIGN                                                   !2, $13
    5     7        ASSIGN                                                   !3, ''
    6     8        STRLEN                                           ~16     !0
          9        ASSIGN                                                   !4, ~16
    7    10      > JMPZ_EX                                          ~18     !0, ->14
         11    >   ISSET_ISEMPTY_CV                                 ~19     !2
         12        BOOL_NOT                                         ~20     ~19
         13        BOOL                                             ~18     ~20
         14    > > JMPZ_EX                                          ~18     ~18, ->17
         15    >   TYPE_CHECK                                  128  ~21     !2
         16        BOOL                                             ~18     ~21
         17    > > JMPZ                                                     ~18, ->77
    8    18    >   ASSIGN                                                   !5, !0
    9    19        COUNT                                            ~23     !2
         20        SUB                                              ~24     ~23, 1
         21        ASSIGN                                                   !6, ~24
   10    22        ASSIGN                                                   !7, !6
         23      > JMP                                                      ->72
   11    24    >   FETCH_DIM_R                                      ~27     !2, !7
         25      > JMPZ_EX                                          ~27     ~27, ->32
         26    >   INIT_FCALL                                               'strstr'
         27        SEND_VAR                                                 !5
         28        FETCH_DIM_R                                      ~28     !2, !7
         29        SEND_VAL                                                 ~28
         30        DO_ICALL                                         $29     
         31        BOOL                                             ~27     $29
         32    > > JMPZ                                                     ~27, ->71
   12    33    >   INIT_FCALL                                               'mb_strrpos'
         34        SEND_VAR                                                 !5
         35        SEND_VAL                                                 '%3C%2Fspan%3E'
         36        DO_ICALL                                         $30     
         37        ASSIGN                                                   !8, $30
   13    38      > JMPZ                                                     !8, ->46
   14    39    >   INIT_FCALL                                               'mb_substr'
         40        SEND_VAR                                                 !5
         41        SEND_VAL                                                 0
         42        SEND_VAR                                                 !8
         43        SEND_VAL                                                 'UTF-8'
         44        DO_ICALL                                         $32     
         45        ASSIGN_OP                                     8          !3, $32
   16    46    >   FETCH_DIM_R                                      ~34     !2, !7
         47        CONCAT                                           ~35     '%3Cspan+class%3D%22fc-red%22%3E', ~34
         48        CONCAT                                           ~36     ~35, '%3C%2Fspan%3E'
         49        ASSIGN                                                   !9, ~36
   17    50        INIT_FCALL                                               'mb_substr'
         51        SEND_VAR                                                 !5
         52        SEND_VAR                                                 !8
         53        SEND_VAR                                                 !4
         54        SEND_VAL                                                 'UTF-8'
         55        DO_ICALL                                         $38     
         56        ASSIGN                                                   !10, $38
   18    57        CONCAT                                           ~40     '---', !10
         58        CONCAT                                           ~41     ~40, '----'
         59        ECHO                                                     ~41
   19    60        INIT_FCALL                                               'preg_replace'
         61        ROPE_INIT                                     3  ~44     '%2F'
         62        FETCH_DIM_R                                      ~42     !2, !7
         63        ROPE_ADD                                      1  ~44     ~44, ~42
         64        ROPE_END                                      2  ~43     ~44, '%2Fi'
         65        SEND_VAL                                                 ~43
         66        SEND_VAR                                                 !9
         67        SEND_VAR                                                 !10
         68        SEND_VAL                                                 1
         69        DO_ICALL                                         $46     
         70        ASSIGN                                                   !5, $46
   10    71    >   PRE_DEC                                                  !7
         72    >   IS_SMALLER_OR_EQUAL                                      0, !7
         73      > JMPNZ                                                    ~49, ->24
   22    74    >   CONCAT                                           ~50     !3, !5
         75        ASSIGN                                                   !5, ~50
         76      > JMP                                                      ->78
   25    77    >   ECHO                                                     !0
         78    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.01 ms | 1404 KiB | 23 Q