The following lines are excluded, and implied. Do not submit with your enties:
Code: Select all
<?php
function bbcode($str) {
Code: Select all
return $str;
}
?>
Moderator: General Moderators
Code: Select all
<?php
function bbcode($str) {
Code: Select all
return $str;
}
?>
Code: Select all
$t=array(array("u","","<span style=\"text-decoration: underline;\">%s</span>"),array("b","","<strong>%s</strong>"),array("i","","<em>%s</em>"),array("img","","<img src=\"%s\" alt=\"\" />"),array("color","=(#?[0-9a-z]+)","<span style=\"color: %s\">%s</span>"),array("s","","<span style=\"text-decoration: line-through;\">%s</span>"));$c=function($m)use(&$u){$f="htmlentities";return sprintf($u[2],$f($m[1]),$f($m[2]));};foreach($t as $u)$str=preg_replace_callback($n="~\[$u[0]$u[1]\](.*?)\[/$u[0](\])~is",$c,$str);return $str;Post the non-minified version next timetasairis wrote:1KB is a lot.
Wrote something at about 900 bytes. Proper HTML. Requires PHP 5.3.
Here's the minified version - 525 bytes.I could reduce it even further but I think the point has been made just fine.Code: Select all
$t=array(array("u","","<span style=\"text-decoration: underline;\">%s</span>"),array("b","","<strong>%s</strong>"),array("i","","<em>%s</em>"),array("img","","<img src=\"%s\" alt=\"\" />"),array("color","=(#?[0-9a-z]+)","<span style=\"color: %s\">%s</span>"),array("s","","<span style=\"text-decoration: line-through;\">%s</span>"));$c=function($m)use(&$u){$f="htmlentities";return sprintf($u[2],$f($m[1]),$f($m[2]));};foreach($t as $u)$str=preg_replace_callback($n="~\[$u[0]$u[1]\](.*?)\[/$u[0](\])~is",$c,$str);return $str;
Insert the usual stuff about file size versus readability and such here.