PHP 中的 ucwords() 函数
phpprogrammingserver side programming更新于 2025/9/16 7:52:17
ucwords() 函数用于将字符串中每个字符的首字符转换为大写。
语法
ucwords(str)
参数
str − 指定的字符串
返回
ucfirst() 函数返回转换后的字符串。
示例
下面是一个例子 −
<?php
echo ucwords("This is it!");
?>
输出
以下是输出 −
This Is It!
示例
让我们看另一个例子 −
<?php $s = "#demo#text"; $sep = '$'; $res = ucwords($s, $sep); print_r($res); ?>
输出
以下是输出 −
#demo#text

