ucfirst() public static méthode

First char to upper, other to lower
public static ucfirst ( $input ) : string
$input
Résultat string
Exemple #1
0
 /**
  * Convert words to PHP Class name
  *
  * @param $input
  * @return string
  */
 public static function className($input)
 {
     $output = preg_replace(array('#(?<=[^A-Z\\s])([A-Z\\s])#i'), ' $0', $input);
     $output = explode(' ', $output);
     $output = array_map(function ($item) {
         $item = preg_replace('#[^a-z0-9]#i', '', $item);
         $item = Filter::ucfirst($item);
         return $item;
     }, $output);
     $output = array_filter($output);
     return implode('', $output);
 }
Exemple #2
0
 public function testUcfirst()
 {
     isSame('Test', Filter::ucfirst('test'));
     isSame('Test', Filter::ucfirst('Test'));
     isSame('Test', Filter::ucfirst('TEST'));
     isSame('Test', Filter::ucfirst('tEST'));
 }