【发布时间】:2017-06-05 17:35:48
【问题描述】:
我正在使用以下代码将句子中的每个单词大写,但我无法将带有括号的单词大写。
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 中找到一个通用的解决方案/功能。
【问题讨论】:
-
mb_convert_case('[this is the {command line (interface ', MB_CASE_TITLE, 'UTF-8');与那些额外的符号一起工作得很好。
标签: php