Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: utf8

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /phputf8/ucfirst.php

Documentation is available at ucfirst.php

  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. /**
  10. * UTF-8 aware alternative to ucfirst
  11. * Make a string's first character uppercase
  12. * Note: requires utf8_strtoupper
  13. @param string 
  14. @return string with first character as upper case (if applicable)
  15. @see http://www.php.net/ucfirst
  16. @see utf8_strtoupper
  17. @package utf8
  18. @subpackage strings
  19. */
  20. function utf8_ucfirst($str){
  21.     switch utf8_strlen($str) ) {
  22.         case 0:
  23.             return '';
  24.         break;
  25.         case 1:
  26.             return utf8_strtoupper($str);
  27.         break;
  28.         default:
  29.             preg_match('/^(.{1})(.*)$/us'$str$matches);
  30.             return utf8_strtoupper($matches[1]).$matches[2];
  31.         break;
  32.     }
  33. }

Documentation generated on Mon, 05 Mar 2007 21:29:55 +0000 by phpDocumentor 1.3.1