3v4l.org

run code in 300+ PHP versions simultaneously
<?php $title="服务员"; $termKey=array("服务","服务员"); 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])) { $str = '<span class="fc-red">'.$termKey[$i].'</span>'; $newTitle = preg_replace("/$termKey[$i]/i" , $str , $newTitle,1); echo $newTitle; } } } echo $newTitle;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 44
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 16
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 41
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 16
Branch analysis from position: 44
Branch analysis from position: 16
Branch analysis from position: 41
Branch analysis from position: 24
Branch analysis from position: 44
Branch analysis from position: 9
Branch analysis from position: 6
filename:       /in/kd8hr
function name:  (null)
number of ops:  46
compiled vars:  !0 = $title, !1 = $termKey, !2 = $newTitle, !3 = $cur, !4 = $i, !5 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%E6%9C%8D%E5%8A%A1%E5%91%98'
    3     1        ASSIGN                                                   !1, <array>
    4     2      > JMPZ_EX                                          ~8      !0, ->6
          3    >   ISSET_ISEMPTY_CV                                 ~9      !1
          4        BOOL_NOT                                         ~10     ~9
          5        BOOL                                             ~8      ~10
          6    > > JMPZ_EX                                          ~8      ~8, ->9
          7    >   TYPE_CHECK                                  128  ~11     !1
          8        BOOL                                             ~8      ~11
          9    > > JMPZ                                                     ~8, ->44
    5    10    >   ASSIGN                                                   !2, !0
    6    11        COUNT                                            ~13     !1
         12        SUB                                              ~14     ~13, 1
         13        ASSIGN                                                   !3, ~14
    7    14        ASSIGN                                                   !4, !3
         15      > JMP                                                      ->42
    8    16    >   FETCH_DIM_R                                      ~17     !1, !4
         17      > JMPZ_EX                                          ~17     ~17, ->24
         18    >   INIT_FCALL                                               'strstr'
         19        SEND_VAR                                                 !2
         20        FETCH_DIM_R                                      ~18     !1, !4
         21        SEND_VAL                                                 ~18
         22        DO_ICALL                                         $19     
         23        BOOL                                             ~17     $19
         24    > > JMPZ                                                     ~17, ->41
    9    25    >   FETCH_DIM_R                                      ~20     !1, !4
         26        CONCAT                                           ~21     '%3Cspan+class%3D%22fc-red%22%3E', ~20
         27        CONCAT                                           ~22     ~21, '%3C%2Fspan%3E'
         28        ASSIGN                                                   !5, ~22
   10    29        INIT_FCALL                                               'preg_replace'
         30        ROPE_INIT                                     3  ~26     '%2F'
         31        FETCH_DIM_R                                      ~24     !1, !4
         32        ROPE_ADD                                      1  ~26     ~26, ~24
         33        ROPE_END                                      2  ~25     ~26, '%2Fi'
         34        SEND_VAL                                                 ~25
         35        SEND_VAR                                                 !5
         36        SEND_VAR                                                 !2
         37        SEND_VAL                                                 1
         38        DO_ICALL                                         $28     
         39        ASSIGN                                                   !2, $28
   11    40        ECHO                                                     !2
    7    41    >   PRE_DEC                                                  !4
         42    >   IS_SMALLER_OR_EQUAL                                      0, !4
         43      > JMPNZ                                                    ~31, ->16
   15    44    >   ECHO                                                     !2
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.68 ms | 1400 KiB | 17 Q