Home · PHP Scripts · make Clickable Links

cms-zen dot com

online web development :: art and design :: fun stuff
best-budd
sNews Development cms road trip PHP Scripts Photoshop Guides Css Guides Music and video clips Art Gallery Low Light Photography Impression Photography

make Clickable Links

This php script make Clickable Links.

 
<?php

    
function makeClickableLinks($text) {

      
$text eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
        
'<a href="1">1</a>'$text);
      
$text eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
        
'1<a href="http://2">2</a>'$text);
      
$text eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',
        
'<a href="mailto:1">1</a>'$text);
      
    return 
$text;

    }

    
// Usage

    // Email address example
    
$text "you@example.com";
    echo 
makeClickableLinks($text);

    echo 
"<br /><br />";

    
// URL example
    
$text "http://www.example.com";
    echo 
makeClickableLinks($text);

    echo 
"<br /><br />";

    
// FTP URL example
    
$text "ftp://ftp.example.com";
    echo 
makeClickableLinks($text);

?> 

06.12.2006. 16:19