Jump to content

My function can not make a links, why?

- - - - -

  • Please log in to reply
No replies to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
<?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);

 

?>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users