note 41923 deleted from function.substr by tomsommer

From: Date: Mon, 26 Apr 2004 17:10:24 +0000
Subject: note 41923 deleted from function.substr by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-68829@lists.php.net to get a copy of this message
Note Submitter: flobi@flobi.com ---- Perhaps this one should be built in? <? function ucwordsmc($sourcestring) { $sourcestring = ucwords($sourcestring); $returnstring = ""; for($t=0;$t<strlen($sourcestring);$t++) { $checkchar = substr($sourcestring, $t, 1); if (substr($sourcestring, $t, 2) === "Mc") { $returnstring .= substr($sourcestring, $t, 2); $t += 2; $returnstring .= strtoupper(substr($sourcestring, $t, 1)); } else { $returnstring .= $checkchar; } } return $returnstring; } echo ucwordsmc("mcdonald's"); // Returns "McDonald's" ?>

« previous php.notes (#68829) next »