我在 PHP 中有一个字符串,其中包含一些我想更改的字符:例如,这是一段字符串:
$string = '***ROOMS*** The rooms and bathrooms were fully renovated in 2006. They are reported to be quite small but are very clean, well maintained and with modern bathrooms. Rooms are tastefully designed with warm colours and pine wooden furniture. ***RESTAURANTS & BARS*** There is no restaurant in the hotel however there the comfortable ground floor lounge is open all day where ';
我想像这样打印这一段:
<b>ROOMS</b><br>
The rooms and bathrooms were fully renovated in 2006. They are reported to be quite small but are very clean, well maintained and with modern bathrooms. Rooms are tastefully designed with warm colours and pine wooden furniture.<br>
<b>RESTAURANTS & BARS</b><br>
There is no restaurant in the hotel however there the comfortable ground floor lounge is open all day where
这意味着 和 之间的字符串***
变为***
:<br><b> string </b><br>
是否存在使用 str_replace 或模式来做到这一点的方法?
谢谢