3v4l.org

run code in 300+ PHP versions simultaneously
<?php $body = "<p>在过去的一年中,“抖音”通过短视频的形式在人们 <h1>抖音怎么改名字啊?</h1> <img src='https://example.com/test.jpg' title='我想改名字'/></p>"; $keywords = [ 0=>['id'=>1,'title'=>'改名字','url'=>'https://www.example.com/gaimingzi.html'], 1=>['id'=>2,'title'=>'名字','url'=>'https://www.example.com/mingzi.html'], 2=>['id'=>3,'title'=>'短视频','url'=>'https://www.example.com/duanshipin.html'], ]; foreach ($keywords as $keyword) { $body = preg_replace('/(>[^<>]*?)(' . $keyword['title'] . ')([^<>]*?<)/', '$1<a href="'. $keyword['url']. '" target="_blank">$2</a>$3', $body,1); } echo $body;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/2FZ7L
function name:  (null)
number of ops:  21
compiled vars:  !0 = $body, !1 = $keywords, !2 = $keyword
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cp%3E%E5%9C%A8%E8%BF%87%E5%8E%BB%E7%9A%84%E4%B8%80%E5%B9%B4%E4%B8%AD%EF%BC%8C%E2%80%9C%E6%8A%96%E9%9F%B3%E2%80%9D%E9%80%9A%E8%BF%87%E7%9F%AD%E8%A7%86%E9%A2%91%E7%9A%84%E5%BD%A2%E5%BC%8F%E5%9C%A8%E4%BA%BA%E4%BB%AC+%0A%3Ch1%3E%E6%8A%96%E9%9F%B3%E6%80%8E%E4%B9%88%E6%94%B9%E5%90%8D%E5%AD%97%E5%95%8A%3F%3C%2Fh1%3E+%0A%3Cimg+src%3D%27https%3A%2F%2Fexample.com%2Ftest.jpg%27+title%3D%27%E6%88%91%E6%83%B3%E6%94%B9%E5%90%8D%E5%AD%97%27%2F%3E%3C%2Fp%3E'
    7     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $5      !1, ->18
          3    > > FE_FETCH_R                                               $5, !2, ->18
   15     4    >   INIT_FCALL                                               'preg_replace'
          5        FETCH_DIM_R                                      ~6      !2, 'title'
          6        CONCAT                                           ~7      '%2F%28%3E%5B%5E%3C%3E%5D%2A%3F%29%28', ~6
          7        CONCAT                                           ~8      ~7, '%29%28%5B%5E%3C%3E%5D%2A%3F%3C%29%2F'
          8        SEND_VAL                                                 ~8
          9        FETCH_DIM_R                                      ~9      !2, 'url'
         10        CONCAT                                           ~10     '%241%3Ca+href%3D%22', ~9
         11        CONCAT                                           ~11     ~10, '%22+target%3D%22_blank%22%3E%242%3C%2Fa%3E%243'
         12        SEND_VAL                                                 ~11
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !0, $12
   12    17      > JMP                                                      ->3
         18    >   FE_FREE                                                  $5
   18    19        ECHO                                                     !0
   19    20      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.22 ms | 1005 KiB | 14 Q