How would I make links clickable in forums?

poopix

New Member
Messages
15
Reaction score
0
Points
0
I just finished programming my forums in PHP, and when someone posts a link you can't click on it. How would I make it so links that people post are clickable?

I don't allow HTML in the posts though, so people can't use <a>link</a> themselves. Even if I let them use HTML, theres got to be a way to do it besides having them put <a> and </a>.
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
You can search each post, replace it with the str_replace() function and change it into an HTML link before being entered into the forum database.
 

poopix

New Member
Messages
15
Reaction score
0
Points
0
How would I tell when the link ends though? I know I could search the string for 'http://' and replace that with '<a>http://', but how would I figure out where the end of the link is?
 

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
You can just tell PHP to look for the first space after that link. It's been my experience that URLs never have a space in them, so you can tell it to start at 'http://' and simply stop at the first instance of ' ' after that point.
 

poopix

New Member
Messages
15
Reaction score
0
Points
0
Ah, thanks. I feel stupid now for not thinking of that before. >_<
Edit:
Wait, how would I make it a link? Putting <a> before it and </a> after it doesn't make it click-able.

I could put <a href=" before it and "></a> after it, but then there is no text to click on...
 
Last edited:

Hazirak

New Member
Messages
197
Reaction score
0
Points
0
Tell it to find the link and dump it into a variable, then create the links and/or text with it. Basically, a Jimmy-rigged copy-paste procedure.
 
Top