TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-14-2008, 12:27 PM   #1 (permalink)
The Contributor
 
localhost's Avatar
 
Join Date: Apr 2007
Location: Hampshire
Posts: 28
Thanks: 1
localhost is on a distinguished road
Default Parsing URL in text

Hello,

I have paragraphs of text in a database, and I am trying to convert the url's to proper links, e.g. :
This site Google is cool
would be : This site Google is cool

and the same if they had http:// on.

So far my code isn't working, so please I would be grateful if someone could help me achieve above.

Many Thanks,

Steven Gibbons

PHP Code:
if(!empty($data)) {
$url mysql_real_escape_string($_POST['url']);
$text preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@''<a href="$1">$1</a>'$url);
echo 
$text;

__________________
Send a message via MSN to localhost Send a message via Skype™ to localhost
localhost is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design