函式名:ucwords()
適用版本:PHP 4、PHP 5、PHP 7
函式描述:ucwords() 函式將字串中每個單詞的首字母轉換為大寫。
用法: string ucwords ( string $str )
引數:
- str:要轉換的字串。
返回值: 返回轉換後的字串。
示例:
$str = "hello world";
$result = ucwords($str);
echo $result;
輸出: Hello World
示例說明: 在上面的示例中,我們將字串 "hello world" 傳遞給 ucwords() 函式進行轉換。該函式將字串中每個單詞的首字母都轉換為大寫,並返回轉換後的字串 "Hello World"。最後,我們使用 echo 語句將結果輸出到螢幕上。