CoderZone.org

Category: >> PHP Code >> Auto Link Code Bookmark and Share

<< lastnext >>

Snippet Name: Auto Link Code

Description: A code snippet that will automatically make active links from a text link. This works for both 'http:' and 'mailto:' links.

Also see:
» Auto-link text with a given set of
» Convert Minutes to Days, Hours, an...
» Resize and convert an image to a P...
» Convert text to image in php
» Convert RGB to Hex with ASP
» Convert a String to Title Case in ...
» Convert Extensions To Lowercase
» Tabs-To-Space Converter
» Convert Unix time string to a date...
» Convert Dollars And Cents Value to...
» LDAP Timestamp Converter
» Convert entities into normal chara...
» Convert Seconds to Hours:Minutes:S...
» Convert UK Dates To mySQL Format D...
» Convert miles to feet, feet to mil...
» Converting Rows to Columns
» CONVERT
» Convert text to soundex
» Convert between Decimal, Binary, O...
» Convert LONGs to LOBs
» Convert Minutes to Hours
» Convert Hours to Minutes
» Basic currency conversion Convert...
» Update/convert DB field to upperca...
» Convert 12 to 24 hour time and vic...
» Truncate Links Over X Chars long
» Nice 'Read More...' links
» Get Link Text
» Auto Link Maker #2
» Convert Hex to Decimal, Decimal to...

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?php
 
function change_string($str){
     $str = trim($str);
     $str = htmlspecialchars($str);
     $str = preg_replace('#(.*)\@(.*)\.(.*)#','<a href="mailto:\\1@\\2.\\3">Send email</a>',$str);
     $str = preg_replace('=([^\s]*)(www.)([^\s]*)=','<a href="http://\\2\\3" target=\'_new\'>\\2\\3</a>',$str);
     return $str;
   }
 
?>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 8