<?php
echo "THIS FUNCTION MUST MAKE A LINKS";
function autolink($text)
{
$search = array("'[\w\+]+://[A-z0-9\.\?\+\-/_=&%#:;]+[\w/=]+'si","'([^/])(www\.[A-z0-9\.\?\+\-/_=&%#:;]+[\w/=]+)'si","'[\w]+[\w\-\.]+@[\w\-\.]+\.[\w]+'si");
$replace = array('<a href="$0" target="_blank" rel="nofollow">$0</a>','$1<a href="http://$2" target="_blank" rel="nofollow">$2</a>','<a href="mailto:$0" rel="nofollow">$0</a>');
return preg_replace($search, $replace, $text);
}
$zlink="www.google.com";
echo "<br>".autolink($zlink);
?>
why it doesn't work?
echo "THIS FUNCTION MUST MAKE A LINKS";
function autolink($text)
{
$search = array("'[\w\+]+://[A-z0-9\.\?\+\-/_=&%#:;]+[\w/=]+'si","'([^/])(www\.[A-z0-9\.\?\+\-/_=&%#:;]+[\w/=]+)'si","'[\w]+[\w\-\.]+@[\w\-\.]+\.[\w]+'si");
$replace = array('<a href="$0" target="_blank" rel="nofollow">$0</a>','$1<a href="http://$2" target="_blank" rel="nofollow">$2</a>','<a href="mailto:$0" rel="nofollow">$0</a>');
return preg_replace($search, $replace, $text);
}
$zlink="www.google.com";
echo "<br>".autolink($zlink);
?>
why it doesn't work?