PHP大小寫轉(zhuǎn)換詳解
strtoupper()
所有字母變大寫
strtolower()
所有字母變小寫
ucwords()
每個(gè)單詞的首字母轉(zhuǎn)換為大寫
ucfirst()
第一個(gè)單詞首字母變大寫
lcfirst()
第一個(gè)單詞首字母變小寫
示例:
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!
$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!