The Daily Click ::. Forums ::. General Chat ::. Need help with BBCode, PHP
 

Post Reply  Post Oekaki 
 

Posted By Message

Imp of Hazard Games



Registered
  27/08/2003
Points
  781
25th January, 2004 at 06:24:13 -

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?

Image Edited by the Author.

 
I need painters, musicians and animators!

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
25th January, 2004 at 06:40:24 -

check my post on acoders

 
"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

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
25th January, 2004 at 06:42:27 -

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>

 
My signature is never too big!!!

Imp of Hazard Games



Registered
  27/08/2003
Points
  781
26th January, 2004 at 05:07:57 -

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!

 
I need painters, musicians and animators!
   

Post Reply



 



Advertisement

Worth A Click