note 90195 added to function.mb-convert-case

From: Date: Thu, 09 Apr 2009 15:02:47 +0000
Subject: note 90195 added to function.mb-convert-case
Groups: php.notes 
Request: Send a blank email to php-notes+get-153020@lists.php.net to get a copy of this message
Oops.. should have proof read my code. It should read: <?php function titleCase($string, $delimiters = array(" ", "-", "O'"), $exceptions = array("to", "a", "the", "of", "by", "and", "with", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X")) { /* * Exceptions in lower case are words you don't want converted * Exceptions all in upper case are any words you don't want converted to title case * but should be converted to upper case, e.g.: * king henry viii or king henry Viii should be King Henry VIII */ foreach ($delimiters as $delimiter){ $words = explode($delimiter, $string); $newwords = array(); foreach ($words as $word){ if (in_array(strtoupper($word), $exceptions)){ // check exceptions list for any words that should be in upper case $word = strtoupper($word); } elseif (!in_array($word, $exceptions)){ // convert to uppercase $word = ucfirst($word); } array_push($newwords, $word); } $string = join($delimiter, $newwords); } return $string; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 144.167.69.80 ---- Manual Page -- http://www.php.net/manual/en/function.mb-convert-case.php Edit -- https://master.php.net/note/edit/90195 Del: integrated -- https://master.php.net/note/delete/90195/integrated Del: useless -- https://master.php.net/note/delete/90195/useless Del: bad code -- https://master.php.net/note/delete/90195/bad+code Del: spam -- https://master.php.net/note/delete/90195/spam Del: non-english -- https://master.php.net/note/delete/90195/non-english Del: in docs -- https://master.php.net/note/delete/90195/in+docs Del: other reasons-- https://master.php.net/note/delete/90195 Reject -- https://master.php.net/note/reject/90195 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153020) next »