Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用这段代码:
<?php $newstring = preg_replace("/[\n\r]/", "<br />" , $googlemapsbox_text); echo $newstring; ?>
替换 \n 的。我想要实现的目标:限制<br />每行的数量,因此当 preg_replace 发现每行超过 1 \n 时,它们都应该替换为 ONE <br />。
<br />
我希望我的问题对你来说很清楚,对不起奇怪的英语
这应该有效:
preg_replace("/[\n\r]+/", "<br />", // rest of your code =====================^ add a + there on your regex