清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
每个单词的首字母转换为大写:ucwords()
1 |
<?php |
2 |
$foo = 'hello world!'; |
3 |
$foo = ucwords($foo); // Hello World! |
4 |
5 |
$bar = 'HELLO WORLD!'; |
6 |
$bar = ucwords($bar); // HELLO WORLD! |
7 |
$bar = ucwords(strtolower($bar)); // Hello World! |
8 |
?> |
第一个单词首字母变大写:ucfirst()
1 |
<?php |
2 |
$foo = 'hello world!'; |
3 |
$foo = ucfirst($foo); // Hello world! |
4 |
5 |
$bar = 'HELLO WORLD!'; |
6 |
$bar = ucfirst($bar); // HELLO WORLD! |
7 |
$bar = ucfirst(strtolower($bar)); // Hello world! |
8 |
?> |
第一个单词首字母变小写:lcfirst()
1 |
<?php |
2 |
$foo = 'HelloWorld'; |
3 |
$foo = lcfirst($foo); // helloWorld |
4 |
5 |
$bar = 'HELLO WORLD!'; |
6 |
$bar = lcfirst($bar); // hELLO WORLD! |
7 |
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD! |
8 |
?> |
所有 字母变大写:strtoupper()
所有 字母变小写:strtolower()