Thursday 25 August 2016

Text to Link in PHP Functions

Convert URL in content/text to link using this simple PHP function. This PHP function takes a string and converts the URLs in the string to links. This simple function may help in making your simple content into links and referrals to your site.

function url2link($url,$target=0) {
            if($url!="") {
                echo '<a href="'.$url.'"';
                if($target) echo ' target="_blank" ';
                echo '>'.$url.'</a>';
            }
            else echo '<a href="#" onclick="alert(\"No Link Here\")">No Link</a>';
        }

No comments:

Post a Comment