3v4l.org

run code in 300+ PHP versions simultaneously
<?php function GenerateAlbum($match) { return "<div class=\"album\>Do whatever: " . strtoupper($match[1]) . "</div>"; } function FormatModules($text) { $text = preg_replace_callback('~\[album\](.+?)\[/album\]~s', "GenerateAlbum", $text); $find = array( '~\[img width=(.*?) height=(.*?) alt=(.*?)\](https?://.*?\.(?:jpg|jpeg|gif|png))\[/img\]~s', '~\[youtube\](.+?)\[/youtube\]~s', '~\[vimeo\](.+?)\[/vimeo\]~s' ); $replace = array( '<img src="$4" width="$1" height="$2" alt="$3" />', '<iframe src="http://www.youtube.com/embed/$1"></iframe>', '<iframe src="https://player.vimeo.com/video/$1"></iframe>' ); return preg_replace($find, $replace, $text); } echo FormatModules("[vimeo]test1[/vimeo]\n\n[album]test2[/album]\n\njust text\n\n[img width=50 height=100 alt='sumpin good']http://www.example.com/image.gif[/img]\n\n[youtube]test3[/youtube]");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rckMt
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'formatmodules'
          1        SEND_VAL                                                 '%5Bvimeo%5Dtest1%5B%2Fvimeo%5D%0A%0A%5Balbum%5Dtest2%5B%2Falbum%5D%0A%0Ajust+text%0A%0A%5Bimg+width%3D50+height%3D100+alt%3D%27sumpin+good%27%5Dhttp%3A%2F%2Fwww.example.com%2Fimage.gif%5B%2Fimg%5D%0A%0A%5Byoutube%5Dtest3%5B%2Fyoutube%5D'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function generatealbum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rckMt
function name:  GenerateAlbum
number of ops:  9
compiled vars:  !0 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'strtoupper'
          2        FETCH_DIM_R                                      ~1      !0, 1
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                         $2      
          5        CONCAT                                           ~3      '%3Cdiv+class%3D%22album%5C%3EDo+whatever%3A+', $2
          6        CONCAT                                           ~4      ~3, '%3C%2Fdiv%3E'
          7      > RETURN                                                   ~4
    4     8*     > RETURN                                                   null

End of function generatealbum

Function formatmodules:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rckMt
function name:  FormatModules
number of ops:  16
compiled vars:  !0 = $text, !1 = $find, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%7E%5C%5Balbum%5C%5D%28.%2B%3F%29%5C%5B%2Falbum%5C%5D%7Es'
          3        SEND_VAL                                                 'GenerateAlbum'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    8     7        ASSIGN                                                   !1, <array>
   13     8        ASSIGN                                                   !2, <array>
   18     9        INIT_FCALL                                               'preg_replace'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14      > RETURN                                                   $7
   19    15*     > RETURN                                                   null

End of function formatmodules

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
284.1 ms | 1016 KiB | 17 Q