3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/\[@url\|([^|]+)\|(\d+)\](?=(?>.*\R+)+^\[\2]:\s+(\S+))|^\[\d+]:\h+\S+/m'; $str = 'We have [@url|first url|1] and the [@url|the second url|2] and then [@url|the third url|3] [1]: https://www.google.com [2]: www.facebook.com [3]: http://www.amazon.com'; echo preg_replace_callback($re, function($match) { if (isset($match[1])) { return "<a href=\"{$match[3]}\">{$match[1]}</a>"; } }, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B4ptj
function name:  (null)
number of ops:  10
compiled vars:  !0 = $re, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%5C%5B%40url%5C%7C%28%5B%5E%7C%5D%2B%29%5C%7C%28%5Cd%2B%29%5C%5D%28%3F%3D%28%3F%3E.%2A%5CR%2B%29%2B%5E%5C%5B%5C2%5D%3A%5Cs%2B%28%5CS%2B%29%29%7C%5E%5C%5B%5Cd%2B%5D%3A%5Ch%2B%5CS%2B%2Fm'
    4     1        ASSIGN                                                   !1, 'We+have+%5B%40url%7Cfirst+url%7C1%5D+and+%0Athe+%5B%40url%7Cthe+second+url%7C2%5D+and+then+%5B%40url%7Cthe+third+url%7C3%5D%0A%0A%5B1%5D%3A+https%3A%2F%2Fwww.google.com%0A%5B2%5D%3A+www.facebook.com+%0A%5B3%5D%3A+http%3A%2F%2Fwww.amazon.com'
   11     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   15     5        SEND_VAL                                                 ~4
          6        SEND_VAR                                                 !1
   11     7        DO_ICALL                                         $5      
   15     8        ECHO                                                     $5
          9      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/B4ptj
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ISSET_ISEMPTY_DIM_OBJ                         0          !0, 1
          2      > JMPZ                                                     ~1, ->11
   13     3    >   ROPE_INIT                                     5  ~5      '%3Ca+href%3D%22'
          4        FETCH_DIM_R                                      ~2      !0, 3
          5        ROPE_ADD                                      1  ~5      ~5, ~2
          6        ROPE_ADD                                      2  ~5      ~5, '%22%3E'
          7        FETCH_DIM_R                                      ~3      !0, 1
          8        ROPE_ADD                                      3  ~5      ~5, ~3
          9        ROPE_END                                      4  ~4      ~5, '%3C%2Fa%3E'
         10      > RETURN                                                   ~4
   15    11    > > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.48 ms | 1011 KiB | 14 Q