Posted By

pruntrut on 05/22/12


Tagged

php String


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Change string first letter to uppercase


 / Published in: PHP
 

URL: http://www.stoimen.com/blog/2010/09/17/5-php-string-functions-you-need-to-know/

Change string first letter to uppercase

  1. $str1 = 'foo bar';
  2. $str2 = 'Foo bar';
  3. $str3 = 'FOO BAR';
  4. $str4 = 'фуу бар';
  5.  
  6. echo mb_convert_case($str1, MB_CASE_TITLE, 'utf-8'); // Foo Bar
  7. echo mb_convert_case($str2, MB_CASE_TITLE, 'utf-8'); // Foo Bar
  8. echo mb_convert_case($str3, MB_CASE_TITLE, 'utf-8'); // Foo Bar
  9. echo mb_convert_case($str4, MB_CASE_TITLE, 'utf-8'); // Фуу Бар

Report this snippet  

You need to login to post a comment.