gpt4 book ai didi

php - 如何将句子中带括号的单词大写

转载 作者:可可西里 更新时间:2023-10-31 23:01:29 27 4
gpt4 key购买 nike

<分区>

我正在使用以下代码将句子中的每个单词大写,但我无法将带有括号的单词大写。

PHP 代码:

  <?php
$str = "[this is the {command line (interface ";
$output = ucwords(strtolower($str));
echo $output;

输出:

[这是{命令行(界面

但我的预期输出应该是:

[这是{命令行(界面

如何处理带括号的单词?可能有多个括号。

例如:

[{这是({命令行({(接口(interface)

我想在 PHP 中找到一个通用的解决方案/函数。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com