I have a textarea field where users can enter anything they want, similar to a messageboard. What i want to know is:
1. How can I automatically parse if someone enters a URL like so: http://www.a_site.com/ into a clickable LINK
2. Same as above, but with an email.
Thanks
Automatic parse...
Moderator: General Moderators
...
Code: Select all
$text = preg_replace ("/(ftp|http|https):\/\/(їa-z0-9~#%@&:;=!',_crl\(\)\?\/\.\-\+\ї\]\|\*\$\^\{\}]+)/i", "<a href="\\1://\\2" target="_blank">\\1://\\2</a>", $text);
$text = preg_replace ("/(ї\s|"])(ї\w|\.|\-|_]+)@(ї\w||\-|_]+)\.(ї\w|\.|\-|_]+)/i", "\\1<a href="mailto:\\2@\\3.\\4">\\2@\\3.\\4</a>", $text);ahh sweet, thanks a lot 
and as for the smileys, replacing them would be like this?
correct?
and as for the smileys, replacing them would be like this?
Code: Select all
$text = str_replace(":)", "<img src='images/smile.gif'>", $text);
$text = str_replace(":D", "<img src='images/grin.gif'>", $text);
...
...
etc.- cheatboy00
- Forum Contributor
- Posts: 151
- Joined: Sat Jun 29, 2002 10:36 am
- Location: canada
- Contact:
Re: ...
holy <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>, what the hell is that.... what do things liek this....QWERTY wrote:Replace $text with variable with text in it...Code: Select all
$text = preg_replace ("/(ftp|http|https):\/\/(їa-z0-9~#%@&:;=!',_crl\(\)\?\/\.\-\+\ї\]\|\*\$\^\{\}]+)/i", "<a href="\\1://\\2" target="_blank">\\1://\\2</a>", $text); $text = preg_replace ("/(ї\s|"])(ї\w|\.|\-|_]+)@(ї\w||\-|_]+)\.(ї\w|\.|\-|_]+)/i", "\\1<a href="mailto:\\2@\\3.\\4">\\2@\\3.\\4</a>", $text);
/([\s|"])([\w|\.|\-|_]+)@([\w||\-|_]+)\.([\w|\.|\-|_]+)/i
mean, i understand the bit with the @ but whats with all the crazy slashes and stuff....
...
http://www.evolt.org/article/rating/20/22700/index.html
It's the explanation of that "mess"...
It could probably be shorter, but hey, I'm still learning...
Fatalcure, yes, that is correct...