Ucwords doesn't work on new line.. alternative?
PHP ucwords()
does not work on data on a new line, for example:
hello
world
Would o开发者_如何学Goutput as
Hello
world
as it counts both words as one word, even though they are on a new line
How can I get it to upper case each word, even if its on a new line and does not have a space between them?
this is strange. the function uses any white space, including new line characters, as space netween words. is this an html br or a actual newline character?
an alternative function you could try is mb_convert_case()
also, if the new line is made by html, you could try something like this.
nl2br(ucwords(str_replace('<br />', "\n", $input)))
精彩评论