3v4l.org

run code in 500+ PHP versions simultaneously
<?php var_dump(bbc2html('[b]stuff[/b][youtube]abc[/youtube]')); function getYoutubeVideoID($id) { // Just a demo function return '!!'.$id.'!!'; } function bbc2html($content) { $search = '/\[(b|u|i)]([^\[]*)\[\/\1]/'; $replace = '<$1>$2</$1>'; $newContent = preg_replace($search, $replace, $content); return preg_replace_callback( '/\[youtube](.*?)\[\/youtube]/', static function ($matches) { return '<div class="video_wrapper card border-0 shadow text-center m-2" style="width: 25rem;"> <div class="video_trigger card-body" data-source="'.getYoutubeVideoID($matches[1]).'" data-type="youtube"> <p class="text-center">As soon as you click on the button you accept that cookies from YouTube to be loaded</p> <input type="button" class="btn btn-success" value="OK"> <a href="$2" type="button" target="_blank" class="btn btn-danger"><i class="fa-brands fa-youtube pe-1"></i>direct link</a> </div> <div class="video_layer" style="display: none;"> <iframe src="" border="0" data-scaling="true" data-format="16:9" style="height: 0px;"></iframe> </div> </div>'; }, $newContent ); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0hkQj
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL_BY_NAME                                           'bbc2html'
          2        SEND_VAL_EX                                                  '%5Bb%5Dstuff%5B%2Fb%5D%5Byoutube%5Dabc%5B%2Fyoutube%5D'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
   34     6      > RETURN                                                       1

Function getyoutubevideoid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0hkQj
function name:  getYoutubeVideoID
number of ops:  5
compiled vars:  !0 = $id
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    8     1        CONCAT                                               ~1      '%21%21', !0
          2        CONCAT                                               ~2      ~1, '%21%21'
          3      > RETURN                                                       ~2
    9     4*     > RETURN                                                       null

End of function getyoutubevideoid

Function bbc2html:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0hkQj
function name:  bbc2html
number of ops:  14
compiled vars:  !0 = $content, !1 = $search, !2 = $replace, !3 = $newContent
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   13     1        ASSIGN                                                       !1, '%2F%5C%5B%28b%7Cu%7Ci%29%5D%28%5B%5E%5C%5B%5D%2A%29%5C%5B%5C%2F%5C1%5D%2F'
   14     2        ASSIGN                                                       !2, '%3C%241%3E%242%3C%2F%241%3E'
   16     3        FRAMELESS_ICALL_3                preg_replace        ~6      !1, !2
          4        OP_DATA                                                      !0
          5        ASSIGN                                                       !3, ~6
   18     6        INIT_FCALL                                                   'preg_replace_callback'
   19     7        SEND_VAL                                                     '%2F%5C%5Byoutube%5D%28.%2A%3F%29%5C%5B%5C%2Fyoutube%5D%2F'
   20     8        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
   31     9        SEND_VAL                                                     ~8
   32    10        SEND_VAR                                                     !3
   18    11        DO_ICALL                                             $9      
   32    12      > RETURN                                                       $9
   34    13*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0hkQj
function name:  {closure:bbc2html():20}
number of ops:  9
compiled vars:  !0 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
   22     1        INIT_FCALL                                                   'getyoutubevideoid'
          2        FETCH_DIM_R                                          ~1      !0, 1
          3        SEND_VAL                                                     ~1
          4        DO_FCALL                                          0  $2      
          5        CONCAT                                               ~3      '%3Cdiv+class%3D%22video_wrapper+card+border-0+shadow+text-center+m-2%22+style%3D%22width%3A+25rem%3B%22%3E%0A++++++%3Cdiv+class%3D%22video_trigger+card-body%22+data-source%3D%22', $2
          6        CONCAT                                               ~4      ~3, '%22+data-type%3D%22youtube%22%3E%0A++++++++++%3Cp+class%3D%22text-center%22%3EAs+soon+as+you+click+on+the+button+you+accept+that+cookies+from+YouTube+to+be+loaded%3C%2Fp%3E%0A++++++++++%3Cinput+type%3D%22button%22+class%3D%22btn+btn-success%22+value%3D%22OK%22%3E%0A++++++++++%3Ca+href%3D%22%242%22+type%3D%22button%22+target%3D%22_blank%22+class%3D%22btn+btn-danger%22%3E%3Ci+class%3D%22fa-brands+fa-youtube+pe-1%22%3E%3C%2Fi%3Edirect+link%3C%2Fa%3E%0A++++++%3C%2Fdiv%3E%0A++++++%3Cdiv+class%3D%22video_layer%22+style%3D%22display%3A+none%3B%22%3E%0A++++++++++%3Ciframe+src%3D%22%22+border%3D%220%22+data-scaling%3D%22true%22+data-format%3D%2216%3A9%22+style%3D%22height%3A+0px%3B%22%3E%3C%2Fiframe%3E%0A++++++%3C%2Fdiv%3E%0A++++++%3C%2Fdiv%3E'
          7      > RETURN                                                       ~4
   31     8*     > RETURN                                                       null

End of Dynamic Function 0

End of function bbc2html

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.28 ms | 1825 KiB | 16 Q