3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "I went to the dog park yesterday and saw @dog4 playing with @dog8 and @dog3 drinking water -- poor @dog33."; $lookup = [ 'dog4' => 4, 'dog8' => 8, 'dog3' => 3, ]; echo preg_replace_callback( '/@(\w+)/', function ($m) use($lookup) { return isset($lookup[$m[1]]) ? "<span onclick='openPage(\"dogs.php?id={$lookup[$m[1]]}\")' role='link' tabindex='0'>{$m[0]}</span>" : $m[0]; }, $text );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Z2Wp
function name:  (null)
number of ops:  11
compiled vars:  !0 = $text, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'I+went+to+the+dog+park+yesterday+and+saw+%40dog4+playing+with+%40dog8+and+%40dog3+drinking+water+--+poor+%40dog33.'
    5     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'preg_replace_callback'
   12     3        SEND_VAL                                                 '%2F%40%28%5Cw%2B%29%2F'
   13     4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
   15     6        SEND_VAL                                                 ~4
   16     7        SEND_VAR                                                 !0
   11     8        DO_ICALL                                         $5      
   16     9        ECHO                                                     $5
   17    10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7Z2Wp
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $m, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   14     2        FETCH_DIM_R                                      ~2      !0, 1
          3        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~2
          4      > JMPZ                                                     ~3, ->15
          5    >   ROPE_INIT                                     5  ~8      '%3Cspan+onclick%3D%27openPage%28%22dogs.php%3Fid%3D'
          6        FETCH_DIM_R                                      ~4      !0, 1
          7        FETCH_DIM_R                                      ~5      !1, ~4
          8        ROPE_ADD                                      1  ~8      ~8, ~5
          9        ROPE_ADD                                      2  ~8      ~8, '%22%29%27+role%3D%27link%27+tabindex%3D%270%27%3E'
         10        FETCH_DIM_R                                      ~6      !0, 0
         11        ROPE_ADD                                      3  ~8      ~8, ~6
         12        ROPE_END                                      4  ~7      ~8, '%3C%2Fspan%3E'
         13        QM_ASSIGN                                        ~11     ~7
         14      > JMP                                                      ->17
         15    >   FETCH_DIM_R                                      ~12     !0, 0
         16        QM_ASSIGN                                        ~11     ~12
         17    > > RETURN                                                   ~11
   15    18*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.13 ms | 1003 KiB | 14 Q