Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function urltohtml($text)
- {
- return preg_replace_callback('/((http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?)/', 'callback_linker', $text);
- }
- function callback_linker($text)
- {
- $lastchar = substr($text[0], -1, 1);
- if(preg_match('/[^a-zA-Z0-9]/', $lastchar))
- {
- $href = substr($text[0], 0, -1);
- $append = $lastchar;
- }
- else
- {
- $href = $text[0];
- $append = '';
- }
- return "<a href=\"$href\">$href</a>$append";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement