remove line break characters

remove line break characters

Share on social media

preg_replace to get rid of those pesky line break characters.

Particularly for Google Maps bubble’s which take an aversion to non-ASCII chars so as to stop a map rendering altogether.

Non-ACSII characters
This piece of code should be applied when generating a Google Map using any quantity of user generated material.

function removelinebreaks($string)
{
return preg_replace(‘/[\r\n\t]/e’, ‘ ‘, $string);
}

Also make sure you trim your bubbles, and if you’re particularly nervous check the htmlentities and CDATA[ declarations also.

Makes for happier bubbles 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.