3v4l.org

run code in 500+ PHP versions simultaneously
<?php $body = ' <p style="margin:20px auto; font-size:20px;"> hello,this is a new function ,Very happy! oh yes <img src="https://example.com/foo.jpg" title="happy"> <a href="https://www.google.com" title="happy"></a> </p>'; $str = htmlspecialchars_decode($body); $keywords = [ 0=>['id'=>1,'title'=>'function','url'=>'https://www.example.com/goodMood'], 1=>['id'=>2,'title'=>'hello','url'=>'https://www.example.com/happy'], 2=>['id'=>3,'title'=>'happy','url'=>'https://www.example.com/happy1'], ]; $content = array_reduce($keywords, function ($c, $v) { return preg_replace('/(' . $v['title'] . ')/', '<a style="color:red;" href="'. $v['url'] . '">$1</a>', $c); }, $str); echo $content;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/82J94
function name:  (null)
number of ops:  15
compiled vars:  !0 = $body, !1 = $str, !2 = $keywords, !3 = $content
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%0A%3Cp+style%3D%22margin%3A20px+auto%3B+font-size%3A20px%3B%22%3E+hello%2Cthis+is+a+new+function+%2CVery+happy%21+oh+yes+%0A%3Cimg+src%3D%22https%3A%2F%2Fexample.com%2Ffoo.jpg%22+title%3D%22happy%22%3E%0A%3Ca+href%3D%22https%3A%2F%2Fwww.google.com%22+title%3D%22happy%22%3E%3C%2Fa%3E%0A%0A%3C%2Fp%3E'
    9     1        INIT_FCALL                                                   'htmlspecialchars_decode'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !1, $5
   10     5        ASSIGN                                                       !2, <array>
   16     6        INIT_FCALL                                                   'array_reduce'
          7        SEND_VAR                                                     !2
          8        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
   18     9        SEND_VAL                                                     ~8
         10        SEND_VAR                                                     !1
   16    11        DO_ICALL                                             $9      
         12        ASSIGN                                                       !3, $9
   20    13        ECHO                                                         !3
   21    14      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/82J94
function name:  {closure:/in/82J94:16}
number of ops:  12
compiled vars:  !0 = $c, !1 = $v
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   17     2        FETCH_DIM_R                                          ~2      !1, 'title'
          3        CONCAT                                               ~3      '%2F%28', ~2
          4        CONCAT                                               ~4      ~3, '%29%2F'
          5        FETCH_DIM_R                                          ~5      !1, 'url'
          6        CONCAT                                               ~6      '%3Ca+style%3D%22color%3Ared%3B%22+href%3D%22', ~5
          7        CONCAT                                               ~7      ~6, '%22%3E%241%3C%2Fa%3E'
          8        FRAMELESS_ICALL_3                preg_replace        ~8      ~4, ~7
          9        OP_DATA                                                      !0
         10      > RETURN                                                       ~8
   18    11*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
176.7 ms | 2375 KiB | 15 Q