开发者

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)))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜