3v4l.org

run code in 300+ PHP versions simultaneously
<?php function text2bbc($text){ $find = array( '~\[b\](.*?)\[/b\]~s', '~\[i\](.*?)\[/i\]~s', '~\[u\](.*?)\[/u\]~s', '~\[size=(.*?)\](.*?)\[/size\]~s', '~\[color=(.*?)\](.*?)\[/color\]~s' ); $replace = array( '<b>$1</b>', '<i>$1</i>', '<span style="text-decoration:underline;">$1</span>', '<span style="font-size:$1px;">$2</span>', '<span style="color:$1;">$2</span>' ); return preg_replace($find,$replace,$text); } echo text2bbc('this is some [b]bold text[/b] and this is [color=#FF0000]Red text[/color]'); echo'<br>'; echo text2bbc('this text is [i]italic[/i] and this is not'); echo'<br>'; echo text2bbc('here we have [u]underlined[/u] text'); echo'<br>'; echo text2bbc('this is [size=24]24px[/size] font'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKeOE
function name:  (null)
number of ops:  20
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'text2bbc'
          1        SEND_VAL                                                 'this+is+some+%5Bb%5Dbold+text%5B%2Fb%5D+and+this+is+%5Bcolor%3D%23FF0000%5DRed+text%5B%2Fcolor%5D'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   21     4        ECHO                                                     '%3Cbr%3E'
   22     5        INIT_FCALL                                               'text2bbc'
          6        SEND_VAL                                                 'this+text+is+%5Bi%5Ditalic%5B%2Fi%5D+and+this+is+not'
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
   23     9        ECHO                                                     '%3Cbr%3E'
   24    10        INIT_FCALL                                               'text2bbc'
         11        SEND_VAL                                                 'here+we+have+%5Bu%5Dunderlined%5B%2Fu%5D+text'
         12        DO_FCALL                                      0  $2      
         13        ECHO                                                     $2
   25    14        ECHO                                                     '%3Cbr%3E'
   26    15        INIT_FCALL                                               'text2bbc'
         16        SEND_VAL                                                 'this+is+%5Bsize%3D24%5D24px%5B%2Fsize%5D+font'
         17        DO_FCALL                                      0  $3      
         18        ECHO                                                     $3
   27    19      > RETURN                                                   1

Function text2bbc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKeOE
function name:  text2bbc
number of ops:  10
compiled vars:  !0 = $text, !1 = $find, !2 = $replace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
   10     2        ASSIGN                                                   !2, <array>
   17     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
   18     9*     > RETURN                                                   null

End of function text2bbc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.27 ms | 1399 KiB | 19 Q