标签: php
我有一个字符串$name,其中包含姓氏和姓氏,例如Bob Smith,假设用户输入bob smith我希望能够将其姓氏和名字的首字母大写。
$name
Bob Smith
bob smith
我试过这个:$bar = ucfirst(strtolower($bar)); // Hello world!只输出Bob smith。怎么会这样做,以便名字和姓氏都大写?
$bar = ucfirst(strtolower($bar)); // Hello world!
Bob smith
答案 0 :(得分:6)
ucwords
相关功能很有用。
docs http://img196.imageshack.us/img196/2283/h21r.png
答案 1 :(得分:2)
使用ucwords():
ucwords()
$bar = ucwords(strtolower($bar));