Source for file capitalize.php

Documentation is available at capitalize.php

  1. <?php
  2.  
  3. /**
  4.  * Capitalizes the first letter of each word
  5.  * <pre>
  6.  *  * value : the string to capitalize
  7.  *  * numwords : if true, the words containing numbers are capitalized as well
  8.  * </pre>
  9.  * This software is provided 'as-is', without any express or implied warranty.
  10.  * In no event will the authors be held liable for any damages arising from the use of this software.
  11.  *
  12.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  13.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  14.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  15.  * @link       http://dwoo.org/
  16.  * @version    1.1.0
  17.  * @date       2009-07-18
  18.  * @package    Dwoo
  19.  */
  20. function Dwoo_Plugin_capitalize(Dwoo $dwoo$value$numwords=false)
  21. {
  22.     if ($numwords || preg_match('#^[^0-9]+$#',$value))
  23.     {
  24.         return mb_convert_case((string) $value,MB_CASE_TITLE$dwoo->getCharset());
  25.     else {
  26.         $bits explode(' '(string) $value);
  27.         $out '';
  28.         while (list(,$veach($bits)) {
  29.             if (preg_match('#^[^0-9]+$#'$v)) {
  30.                 $out .=    ' '.mb_convert_case($vMB_CASE_TITLE$dwoo->getCharset());
  31.             else {
  32.                 $out .=    ' '.$v;
  33.             }
  34.         }
  35.  
  36.         return substr($out1);
  37.     }
  38. }

Documentation generated on Sat, 18 Jul 2009 21:04:38 +0200 by phpDocumentor 1.4.0