我正在使用以下代码来对句子中的每个单词进行大写处理,但我无法使用附加括号的单词进行大写处理。如何在句子中大写带括号的单词
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 –