每個(gè)單詞的首字母轉(zhuǎn)換為大寫(xiě):ucwords()
<?php $foo = 'hello world!'; $foo = ucwords($foo); // Hello World! $bar = 'HELLO WORLD!'; $bar = ucwords($bar); // HELLO WORLD! $bar = ucwords(strtolower($bar)); // Hello World! ?>
相關(guān)視頻教程推薦:php視頻教程
第一個(gè)單詞首字母變大寫(xiě):ucfirst()
<?php $foo = 'hello world!'; $foo = ucfirst($foo); // Hello world! $bar = 'HELLO WORLD!'; $bar = ucfirst($bar); // HELLO WORLD! $bar = ucfirst(strtolower($bar)); // Hello world! ?>
第一個(gè)單詞首字母變小寫(xiě):lcfirst()
<?php $foo = 'HelloWorld'; $foo = lcfirst($foo); // helloWorld $bar = 'HELLO WORLD!'; $bar = lcfirst($bar); // hELLO WORLD! $bar = lcfirst(strtoupper($bar)); // hELLO WORLD! ?>
知識(shí)點(diǎn)補(bǔ)充:
所有字母變大寫(xiě):strtoupper()
所有字母變小寫(xiě):strtolower()
相關(guān)文章教程推薦:php教程