Tutorial on creating a simple BBCode function with PHP

Basically BB code is used to make code easier to write and doesn’t require the help of other tags like HTMLso that it can automatically change the code used.
BB code is used to CMS in the form of a forum and so far many sites refer to BB code as Codes forum. As in vBulletin, Simple Machine and Vanilla also use bbcode when writing some HTML tags.
Usually BB code supports: bold, underlined, italic, URL, UserID, ForumID. And all of this is called with brackets in the form [ dan ]. Creating such a function is very simple and if you want to create it please refer to the code below first!
BB code function
"$1","/[s](.*?)[/s]/is" => "$1","/[i](.*?)[/i]/is" => "$1","/[u](.*?)[/u]/is" => "$1","/[url=(.*?)](.*?)[/url]/is" => "$2");?>
Example of writing content
Content conjuring
There are three structures that are used to help the BB Code function get started The first ie start function on string $ bbcode Used as an array so that it can be easily called from its key and value. Using regexp code as it will later use preg_replace to display it.
The second ie the content using a string $ contentThey practice using only the URL code.
The third ie appearance of the string $ content which uses 3 manual PHP functions: preg_replace, array_keys and array_values, so preg_replace basically changes the code from array_values to array_keys, which is in the string $ bbcode.
The above code isn’t hard to understand, and if you look carefully, only code one changes to code two and so on. to add another BB code code, please add the code to the array in the $ bbcode string as below.
"/[kode](.*?)[/kode]/is" => "$1 ","/[anu](.*?)[/anu]/is" => "$1 ");
Please replace it with the tag format you want, if you want to add another code below please add it Comma. sign at the end of the values as above and don’t forget to end with closing brackets and a semicolon.
This method can also be done as a Smiley emoticon, just change the array and you can create your own
Hopefully useful and good luck