Change string first letter to uppercase


/ Published in: PHP
Save to your folder(s)

Change string first letter to uppercase


Copy this code and paste it in your HTML
  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'); // Фуу Бар

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.