我正在使用以下代碼來對句子中的每個單詞進行大寫處理,但我無法使用附加括號的單詞進行大寫處理。如何在句子中大寫帶括號的單詞
PHP代碼:
<?php
$str = "[this is the {command line (interface ";
$output = ucwords(strtolower($str));
echo $output;
輸出:
[this Is The {command Line (interface
但是我預期的輸出應該是:
[This Is The {Command Line (Interface
如何處理帶括號的單詞? 可能有多個括號。
例如:
[{this is the ({command line ({(interface
我想找到PHP的通用解決方案/功能。
查看此頁http://php.net/manual/en/function.ucwords.php –