Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

PHP: convert emails to mailto links

It looks like an easy task, but I decided to share it.

I think that preg_replace function is the best option for doing that. It's just one line of code:

preg_replace('/([a-zA-Z0-9_\\-\\.]*@\\\\S+\\\\.\\\\w+)/', '<a href="mailto:$1">$1</a>', $str);
If you enjoy this post, share it on Twitter, Facebook or LinkedIn.