仅在其行上删除术语

问题描述 投票:3回答:1

我有这个:

$text = '
   hello world
    
    hello
';

如果我自己删除  ,该怎么办?因此,在上面的示例中,应删除第二个 。结果应为:

$text = '
   hello world

    hello
';

到目前为止我尝试过的>

通过str_replace(),我可以:

$text = str_replace(' ', '', $text);

但是这将删除 all

个实例,不仅是在其单独的行上。

我有这个:$ text ='hello world'hello';仅当它自己行时才如何删除?因此,在上面的示例中,第二个应该是...

php str-replace
1个回答
0
投票

这也许可以帮助您:

© www.soinside.com 2019 - 2024. All rights reserved.