开发者

Ucwords doesn't work on new line.. alternative?

开发者 https://www.devze.com 2023-02-04 06:51 出处:网络
PHP ucwords() does not work on data on a new line, for example: hello world Would o开发者_如何学Goutput as

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

精彩评论

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