Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best function for Title capitlization?

Tags:

php

Should I be using mb_convert_case with MB_CASE_TITLE or ucwords? Or something else? What will the differences be?

like image 350
bgcode Avatar asked Sep 20 '25 16:09

bgcode


1 Answers

It depends.

mb_convert_case() is multibyte safe. ucwords() is not.

mb_convert_case() requires an extension that is not always available. ucwords() is always available.

So if your application will only ever use single-byte encodings then ucwords() gives you better portability.

But if your application might need to process multi-byte encodings then ucwords() will fail you.