Convert URLs within String into hyperlinks


/ Published in: PHP
Save to your folder(s)

This function converts URLs and e-mail addresses within a string into clickable hyperlinks.


Copy this code and paste it in your HTML
  1. $url = "Jose Robinson Blog http://www.joserobinson.com/blog";
  2. $url = preg_replace("#https?://[A-z0-9\./-_+&\#@:%~=]+#", '<a href="$0">$0</a>', $url);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.