Jump to content

Recommended Posts

$str= preg_replace("/([^A-z0-9])(http|ftp|https)([\:\/\/])([^\\s]+)/","<a href=\"$2$3$4\">$2$3$4</a>",$str);

 

From http://codingforums.com/showthread.php?t=181757

 

Also was discussed previously in the regex forum at http://www.phpfreaks.com/forums/index.php/topic,287639.0.html. Please review the proper sections and search for your answer before posting, as chances are it has been answered many times before.

It's not working in my case...

 

I've a function that takes some text in the field an converts that into url if it's present....however,it displays the whole text and url as an hyperlink...and when clicked on text it displays page doesn't exist,which it is supposed to display...

 

function make_url_link($url)

{

if(empty($url)) {

        return;

    }

$url= preg_replace("/([^A-z0-9])(http|ftp|https)([\:\/\/])([^\\s]+)/","<a href=\"$2$3$4\">$2$3$4</a>",$url);

    return '<a href="'.$url.'">'.$url.'</a>';

}

 

 

Any suggestions???

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.