note 29618 deleted from function.explode by bjori

From: Date: Mon, 25 Sep 2006 08:14:30 +0000
Subject: note 29618 deleted from function.explode by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117613@lists.php.net to get a copy of this message
Note Submitter: jasenko at get2net dot dk ---- This is example of converting strings to proper case (as we know it from VB). It shows use of PHP string functions explode(), substr() and trim() along with case converting functions. It's quite simple ! <?php function properCase($strIn) { $arrTmp = explode(" ", trim($strIn)); for($i=0; $i < count($arrTmp);$i++) { $firstLetter = substr($arrTmp[$i],0,1); $rest = substr($arrTmp[$i],1,strlen($arrTmp[$i])); $arrOut[$i] = strtoupper($firstLetter).strtolower($rest); } for($j=0; $j < count($arrOut); $j++) $retVal .= $arrOut[$j]." "; return trim($retVal); } ?> Hope this can be usefull to someone (I know it was to me ...).

« previous php.notes (#117613) next »