PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/MantisBT/library/utf8/ucfirst.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 34 lines | 15 code | 2 blank | 17 comment | 1 complexity | 3907b74d90c65e4792ebaa30a3b41538 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /**
  3. * @version $Id: ucfirst.php,v 1.1 2006/02/25 13:50:17 harryf Exp $
  4. * @package utf8
  5. * @subpackage strings
  6. */
  7. //---------------------------------------------------------------
  8. /**
  9. * UTF-8 aware alternative to ucfirst
  10. * Make a string's first character uppercase
  11. * Note: requires utf8_strtoupper
  12. * @param string
  13. * @return string with first character as upper case (if applicable)
  14. * @see http://www.php.net/ucfirst
  15. * @see utf8_strtoupper
  16. * @package utf8
  17. * @subpackage strings
  18. */
  19. function utf8_ucfirst($str){
  20. switch ( utf8_strlen($str) ) {
  21. case 0:
  22. return '';
  23. break;
  24. case 1:
  25. return utf8_strtoupper($str);
  26. break;
  27. default:
  28. preg_match('/^(.{1})(.*)$/us', $str, $matches);
  29. return utf8_strtoupper($matches[1]).$matches[2];
  30. break;
  31. }
  32. }