30th September, 2010
Find and replace html links with PHP
Here is a great function that I’m using in a handy string utility class. It takes a string of text (plain text or html) and finds any web addresses ie http://www.purepixel.co.uk/ and turns them into html links (<a> tags).
function parseLinks($str) { return ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $str); }
Related Posts
- Using Swift Mailer plugins with Laravel 4
- Using Selenium Server 2 and PHPUnit to automate browser acceptance testing
- Laravel 4 First Thoughts
- UK Data.gov Property Price Mash Up
- Problems embedding true type fonts with TCPDF
- Re-routing emails to a development email address with php and SwiftMailer
- php $_FILES array shorter than expected and max_file_uploads sillyness