Reputation: 1629
Im using this piece of code:
<?php $newstring = preg_replace("/[\n\r]/", "<br />" , $googlemapsbox_text); echo $newstring; ?>
To replace the \n's. What I would like to achieve: limit the amount of <br />
per line, so when preg_replace finds more than 1 \n per line, they ALL should be replaced with ONE <br />
.
I hope my question is clear to you, sorry for the weird English
Upvotes: 0
Views: 183
Reputation: 60536
This should work:
preg_replace("/[\n\r]+/", "<br />", // rest of your code
=====================^ add a + there on your regex
Upvotes: 2