3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = "<div> <img src='/logo.png'>[:ru]Привет мир[:en]Hello World[:] </div>"; $lang = 'ru'; echo preg_replace_callback('|\[:.*\[:\]|isuU', function ($find) use ($lang) { //print_r($matches); echo '|\[\:' + $lang + '\](.*)\[\:|isuU'; if (preg_match('|\[\:' + $lang + '\](.*)\[\:|isuU', $find[0], $matches)) { return $matches[1]; } }, $html);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NgKMD
function name:  (null)
number of ops:  11
compiled vars:  !0 = $html, !1 = $lang
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cdiv%3E%0A%3Cimg+src%3D%27%2Flogo.png%27%3E%5B%3Aru%5D%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82+%D0%BC%D0%B8%D1%80%5B%3Aen%5DHello+World%5B%3A%5D%0A%3C%2Fdiv%3E'
    7     1        ASSIGN                                                   !1, 'ru'
    9     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%7C%5C%5B%3A.%2A%5C%5B%3A%5C%5D%7CisuU'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNgKMD%3A9%240'
          5        BIND_LEXICAL                                             ~4, !1
   16     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        ECHO                                                     $5
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FNgKMD%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NgKMD
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $find, !1 = $lang, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   12     2        ADD                                              ~3      '%7C%5C%5B%5C%3A', !1
          3        ADD                                              ~4      ~3, '%5C%5D%28.%2A%29%5C%5B%5C%3A%7CisuU'
          4        ECHO                                                     ~4
   13     5        INIT_FCALL                                               'preg_match'
          6        ADD                                              ~5      '%7C%5C%5B%5C%3A', !1
          7        ADD                                              ~6      ~5, '%5C%5D%28.%2A%29%5C%5B%5C%3A%7CisuU'
          8        SEND_VAL                                                 ~6
          9        FETCH_DIM_R                                      ~7      !0, 0
         10        SEND_VAL                                                 ~7
         11        SEND_REF                                                 !2
         12        DO_ICALL                                         $8      
         13      > JMPZ                                                     $8, ->16
   14    14    >   FETCH_DIM_R                                      ~9      !2, 1
         15      > RETURN                                                   ~9
   16    16    > > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.63 ms | 1396 KiB | 17 Q