<?php class MyClass {
function preg_callback_url($matches)
{
//var_dump($matches);
$url = $matches[1].$matches[2];
$text = '';
$pos = strpos($url,' ');
if ($pos!==FALSE) {
$text = trim(substr($url,$pos+1));
$url = substr($url,0,$pos);
}
return '<a href="'.$url.'" rel="nofollow">'.(($text!='') ? $text : $url).'</a>';
}
function ParseText($text)
{
return preg_replace_callback('/\[(http|https|ftp)(.*?)\]/iS',array( &$this, 'preg_callback_url'), $text);
}
} ?>
function preg_callback_url($matches)
{
//var_dump($matches);
$url = $matches[1].$matches[2];
$text = '';
$pos = strpos($url,' ');
if ($pos!==FALSE) {
$text = trim(substr($url,$pos+1));
$url = substr($url,0,$pos);
}
return '<a href="'.$url.'" rel="nofollow">'.(($text!='') ? $text : $url).'</a>';
}
function ParseText($text)
{
return preg_replace_callback('/\[(http|https|ftp)(.*?)\]/iS',array( &$this, 'preg_callback_url'), $text);
}
} ?>
Comments
Post a Comment