remove line break characters

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 :)

Related Reading

Fitting flexible solar panels to a narrowboat

This is a short guide to installing flexible solar panels to a narrowboat. How long do flexible solar panels last for? No doubt, less long...

Top 14 Tips for Amazon Flex drivers

Top 14 tips for Amazon Flex drivers (UK). Map of Amazon Flex depots. Amazon Flex contract for drivers.

Transfer .apk
Top 10 apps for visitors to China

If you’re planning a trip, or maybe living there as an expat, these are the apps you’re going to want to have installed to your...

Is google analytics shit? WordPress metrics for SEO.

Background So, I’ve been running this site for around 1 month now without hitches, the homepage sorted and the page structure hieracy as it should...

Under the national park sign
Rinjani 3-day trek from Sanaru

A hiking trip for Mount Rinjani in Lombok

Author: Michael Tyler

Owner and main contributor to the michaeltyler.co.uk, a site about my travels and day to day life on the canal.

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.