note 14902 added to function.ucwords.php

From: Date: Mon, 20 Aug 2001 14:38:47 +0000
Subject: note 14902 added to function.ucwords.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16917@lists.php.net to get a copy of this message
An evolution of the previous (a little more compact I think): $name="ReaLLY s'CREWED Name, JR."; $break=1; for ($i=0; $i < strlen($name); $i++) { $subed=substr($name,$i,1); # if its a letter or num if (((ord($subed) > 64) && (ord($subed) < 123)) || ((ord($subed) > 48) && (ord($subed) < 58))) { if ($break) { $newname .= strtoupper($subed); } else { $newname .= strtolower($subed); } $break=0; } else { # not a letter - a boundary $newname .= $subed; $break=1; } } echo "$newname\n"; http://www.php.net/manual/en/function.ucwords.php

« previous php.notes (#16917) next »