Hi John:
jtjohnston wrote:
>
> I'm looking for a function that will find occurences of urls in any
> given string and do this:
>
> http://www.nowhere.com/
> becomes
> <a href="http://www.nowhere.com/">http://www.nowhere.com/</a>
<?php
$Val = "body of text you want to process...";
$Val =
eregi_replace("(http://|https://|ftp://|gopher://|news:|mailto:)([[:alnum:]/!#$%&'()*+,.:;=?@_~-]+)([[:alnum:]/!#$%&'()*+:;=?@_~-])",
'<a href="\\1\\2\\3">\\1\\2\\3</a>', "$Val");
?>
You'll have to undo the line wrapping before you use that.
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php