3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '[[Яша|ya.ru]] qwerty [[Яков|yandex.ru]]'; $dict = ['Яша' => 'Яков', 'Яков' => 'Яша']; $res = []; echo preg_replace_callback( '~\[\[(.*?)\|(.*?)]]~', function ($m) use ($dict, &$res) { array_push($res, $m[1]); return '<a href="'. mb_strtoupper($m[2]) . '" target="_blank">'. (isset($dict[$m[1]]) ? $dict[$m[1]] : $m[1]) . '</a>'; }, $str ) . "\n"; print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BkYsj
function name:  (null)
number of ops:  17
compiled vars:  !0 = $str, !1 = $dict, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%5B%D0%AF%D1%88%D0%B0%7Cya.ru%5D%5D+qwerty+%5B%5B%D0%AF%D0%BA%D0%BE%D0%B2%7Cyandex.ru%5D%5D'
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'preg_replace_callback'
    8     4        SEND_VAL                                                 '%7E%5C%5B%5C%5B%28.%2A%3F%29%5C%7C%28.%2A%3F%29%5D%5D%7E'
    9     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBkYsj%3A9%240'
          6        BIND_LEXICAL                                             ~6, !1
          7        BIND_LEXICAL                                             ~6, !2
   16     8        SEND_VAL                                                 ~6
   17     9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $7      
   18    11        CONCAT                                           ~8      $7, '%0A'
         12        ECHO                                                     ~8
   19    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBkYsj%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BkYsj
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $m, !1 = $dict, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   10     3        INIT_FCALL                                               'array_push'
          4        SEND_REF                                                 !2
          5        FETCH_DIM_R                                      ~3      !0, 1
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                                 
   12     8        INIT_FCALL                                               'mb_strtoupper'
          9        FETCH_DIM_R                                      ~5      !0, 2
         10        SEND_VAL                                                 ~5
         11        DO_ICALL                                         $6      
         12        CONCAT                                           ~7      '%3Ca+href%3D%22', $6
   13    13        CONCAT                                           ~8      ~7, '%22+target%3D%22_blank%22%3E'
   14    14        FETCH_DIM_R                                      ~9      !0, 1
         15        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~9
         16      > JMPZ                                                     ~10, ->21
         17    >   FETCH_DIM_R                                      ~11     !0, 1
         18        FETCH_DIM_R                                      ~12     !1, ~11
         19        QM_ASSIGN                                        ~13     ~12
         20      > JMP                                                      ->23
         21    >   FETCH_DIM_R                                      ~14     !0, 1
         22        QM_ASSIGN                                        ~13     ~14
         23    >   CONCAT                                           ~15     ~8, ~13
   15    24        CONCAT                                           ~16     ~15, '%3C%2Fa%3E'
         25      > RETURN                                                   ~16
   16    26*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBkYsj%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.49 ms | 1400 KiB | 21 Q