php首字母小写怎么转大写
admin 阅读:68 2024-03-01
php首字母小写转大写的方法
每个单词的首字母转换为大写:ucwords()
<?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! ?>
ucwords() 函数把字符串中每个单词的首字符转换为大写。
第一个单词首字母变大写:ucfirst()
<?php $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! ?>
ucfirst() 函数把字符串中的首字符转换为大写。
以上就是php首字母小写怎么转大写的详细内容,更多请关注VIP共享吧其它相关文章!
声明
1、部分文章来源于网络,仅作为参考。 2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!