PHP Please Help.
Hello,
Im quite new to php and am just teaching myself it. I am building a website for myself and some friends to keep there code and files etc on.
What i want to know how to do is when code when it is submitted in an article to the database how can it be output so it is nice and formatted. Like it is on HBH for example?
Of course i have tried google but i am not totaly sure what i should search for.
Any help would be greatly appreciated!
Thanks all.
Relentless.
Not 100% sure of what you're asking… but I think….
If you're storing an article somewhere and you want it to be bold and such… shouldn't you parse the article (in the page that's displaying it) for certain things like whichever code tags you want to use, then convert those to their HTML equivilant, and then display that.
I hope I helped, Reaper
If you want bbcode take a look at bbcode.phps and bbcodes.xml (links may die on occasion).
Edit: linkified urls
Maybe something like:
... your code....
str_replace("{b]","<b>",$string);
str_replace("{/b]","</b>",$string);
... then your code to display it...
Hope I helped, Reaper
EDIT:
That post didn't work because it removed my BBCode examples. I've edited it… using the { instead of [
Or just nl2br
Edit: Reaper your code fails because it allows people to leave a tag unclosed. Of course you could make workarounds, but I suggest you instead use regular expressions, see the code I linked to in my above post.