pastebin - collaborative debugging tool
blankb.kpaste.net RSS


Rename First uc lower
Posted by Anonymous on Sun 21st Jan 2018 01:35
raw | new post

  1. <?
  2. function ucname($string) {
  3.     $string =ucwords(strtolower($string));
  4.  
  5.     foreach (array('-', '\'','_') as $delimiter) {
  6.       if (strpos($string, $delimiter)!==false) {
  7.         $string =implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
  8.       }
  9.     }
  10.     return $string;
  11. }
  12.  
  13. $f = fopen( 'php://stdin', 'r' );
  14.  
  15. while( $line = fgets( $f ) )
  16. {
  17.   $line=trim($line);
  18.   $line=str_replace(" ","_",$line);
  19.   echo "mv '$line' ";
  20.   $parts=ucname($line);
  21.   echo "'$parts'\n";
  22. }
  23.  
  24.   fclose( $f );
  25. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at