text to links

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

text to links

Post by hob_goblin »

In mostly all the scripts i see if you type out http:// something .com
it will replace it with a link

I know this is so incredibly easy to do, but I was working with it earlier, and I was just drawing a blank..
i know it's

$foo = ereg_replace("something", "something", "$foo");
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

you could use srt_replace also to achieve that, but RE could be easier
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

im not worried about being able to replace strings...
just confused what to search for, and especially how to replace it without losing the link
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

search for 'http://' and '.com, .net, ect.' But searching for the '.com' and the rest can be a bitch. Unless you feel like typing out a list of them.
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

hmm, well i can probably figure that out unless someone posts it, but i just wasn't sure if there was a way to put it all in one line
Post Reply