php ucfirst无法使用特殊字符和空格

时间:2018-06-23 12:51:55

标签: php laravel

当前,我有一个带有特殊字符和空格的字符串。因此,我只想在每个破折号之后将字符串的第一个字符大写。

$theString = """
  \r\n
  \r\n
                fraud - conspiracy to defraud - breach of trust - whether claims proven - locus standi - breach of\r\n
                fiduciary duty and equitable fraud - prima facie case - limitation and laches - quantum and costs -\r\n
                whether appellate intervention warranted\r\n
            </i>\r\n
        </p>\r\n
    </CATCHWORDS>
  """

我尝试了

$result = ucfirst($theString);
echo $result;
//result:

        """
     \r\n
     \r\n
              fraud - conspiracy to defraud - breach of trust - whether claims proven - locus standi - breach of\r\n
            fiduciary duty and equitable fraud - prima facie case - limitation and laches - quantum and costs -\r\n
            whether appellate intervention warranted\r\n
        </i>\r\n
    </p>\r\n
</CATCHWORDS> """


?>

预期:

   """
 \r\n
 \r\n
          Fraud - Conspiracy to defraud - Breach of trust - Whether claims proven - Locus standi - Breach of\r\n
        fiduciary duty and equitable fraud - Prima facie case - Limitation and laches - Quantum and costs -\r\n
        Whether appellate intervention warranted\r\n
    </i>\r\n
</p>\r\n
</CATCHWORDS>  
"""

0 个答案:

没有答案