how 2 Display clickable Links from plain text from database.

gesf

New member
You need some REGEX for that. Here you have a great function to make it for you:
Code:
<?php

// -------------------------------------------------------------------
// Auto make a link from a string
// -------------------------------------------------------------------

function AutoLink($input){
    $output = eregi_replace("(http|https|ftp)://([a-z0-9\-\./]+))","<a href=\"\\0\">\\0</a>", $input);
    $output = eregi_replace("(([a-z0-9\-\.]+)@([a-z0-9\-\.]+)\.([a-z0-9]+))","<a href=\"mailto:\\0\">\\0</a>", $output);
    return $output;
}

?>
Example:
Code:
<?php

print AutoLink($_POST['message']);

?>
 
Back
Top