gpt4 book ai didi

PHP Preg 替换之间的行

转载 作者:行者123 更新时间:2023-11-29 21:40:01 26 4
gpt4 key购买 nike

<p>Inspection and treatment will be conducted to areas prone to Mouse infestation by our Service Specialist during the routine visits. This includes the sewerage system servicing the property.</p>

<p>Apart from treating the sewerage manhole, application of residual coat will also be done at strategic areas prone to Mouse activity/harborages, and when necessary, baits will be placed and application of gel will be carried out.</p>

<p>Preparations used are safe to humans and animals and is approved by the Ministry.</p>

上面是我要记录到mysql中的文本,我想将它们修剪成

<p>Inspection and treatment will be conducted to areas prone to Mouse infestation by our Service Specialist during the routine visits. This includes the sewerage system servicing the property.</p><p>Apart from treating the sewerage manhole, application of residual coat will also be done at strategic areas prone to Mouse activity/harborages, and when necessary, baits will be placed and application of gel will be carried out.</p><p>Preparations used are safe to humans and animals and is approved by the Ministry.</p>

我使用了以下代码:

$service_desc = preg_replace('/\s+/', ' ', $service_desc);

但是代码没有解决字符串文本之间的间距问题,如何删除之间的空白以获得我想要的结果。

谢谢!

最佳答案

如果你想删除行尾字符,这不是更容易吗?

$service_desc = str_replace("\r\n", '', $service_desc);

$service_desc = str_replace("\n", '', $service_desc);

抱歉,如果这不是您所要求的。

关于PHP Preg 替换之间的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34608096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com