Can someone please give me a function for BBcode in PHP? I have made one myself using eregi_replace, but it seems to kill everything with
Fatal error: Maximum execution time of 30 seconds exceeded in /some_folders/hazard-games.com/htdocs/test/bbcode.php on line 39
What is that and how do I fix it?
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G
Well, i did this differently (i used a file to store all of the code):
i used an array with all the code in, like:
$code=array(
'[u]' => '<*u>',
'[/u]' => '<*/u>'
);
without th *s
(if you add more, the line before ); must not end in a comma)
then this function (in the same file)
function code( $t )
{
$search = array_keys( $GLOBALS['code'] );
$t = str_replace( $search, $GLOBALS['code'], $t );
return $t;
}
then in the pages you want the code to appear on just do include "code.php"
then:
$text=code($text);
(so if text contains the [u] or [/u] it will change them to <*u> and <*/u>
Okay, thanks men.
I did it in my own, maybe incomfortable but simple way.
First I used eregi_replace, but it seemed to take LONG time, but I replaced them to str_replace and now it's lighting fast!