我在 PHP 中有一个文本字符串:
<strong> MOST </strong> of you may have a habit of wearing socks while sleeping.
<strong> Wear socks while sleeping to prevent cracking feet</strong>
<strong> Socks helps to relieve sweaty feet</strong>
我们可以看到,第一个强标签是
<strong> MOST </strong>
我想删除第一个强标签,并将其中的单词变成 ucwords(首字母大写)。像这样的结果
Most of you may have a habit of wearing socks while sleeping.
<strong> Wear socks while sleeping to prevent cracking feet</strong>
<strong> Socks helps to relieve sweaty feet</strong>
我尝试过使用爆炸功能,但它似乎不是我想要的。这是我的代码
<?php
$text = "<strong>MOST</strong> of you may have a habit of wearing socks while sleeping. <strong> Wear socks while sleeping to prevent cracking feet</strong>. <strong> Socks helps to relieve sweaty feet</strong>";
$context = explode('</strong>',$text);
$context = ucwords(str_replace('<strong>','',strtolower($context[0]))).$context[1];
echo $context;
?>
我的代码只有结果
Most of you may have a habit of wearing socks while sleeping. <strong> Wear socks while sleeping to prevent cracking feet