-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbbcode.php
More file actions
22 lines (22 loc) · 997 Bytes
/
bbcode.php
File metadata and controls
22 lines (22 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
function parse_bbcode_html($string) {
$bbcode = array("[b]"=>"<strong>", "[/b]"=>"</strong>",
"[i]"=>"<em>", "[/i]"=>"</em>",
"[u]"=>"<span style='text-decoration:underline;'>", "[/u]"=>"</span>",
"[s]"=>"<del>", "[/s]"=>"</del>",
"[sub]"=>"<sub>","[/sub]"=>"</sub>",
"[sup]"=>"<sup>","[/sup]"=>"</sup>",
"[h1]"=>"<h1>","[/h1]"=>"</h1>",
"[h2]"=>"<h2>","[/h2]"=>"</h2>",
"[h3]"=>"<h3>","[/h3]"=>"</h3>",
"[h4]"=>"<h4>","[/h4]"=>"</h4>",
"[h5]"=>"<h5>","[/h5]"=>"</h5>",
"[h6]"=>"<h6>","[/h6]"=>"</h6>",
"[code]"=>"<code>","[/code]"=>"</code>",
"[q]"=>"<blockquote class='style'>", "[/q]"=>"</blockquote>");
$bbtags = array_keys($bbcode);
$htmltags = array_values($bbcode);
$parsed = str_replace($bbtags, $htmltags, $string);
return $parsed;
}
?>