note 87704 added to function.mb-convert-case

From: Date: Wed, 17 Dec 2008 16:42:55 +0000
Subject: note 87704 added to function.mb-convert-case
Groups: php.notes 
Request: Send a blank email to php-notes+get-148273@lists.php.net to get a copy of this message
Retouching Alex's example so it works: function titleCase($string, $exceptions = array('to', 'a', 'the', 'of', 'by', 'and', 'with', 'UI', 'V','X')) { $words = explode(" ", $string); $newwords = array(); foreach ($words as $word) { if (!in_array($word, $exceptions)) { $word = strtolower($word); $word = ucfirst($word); } array_push($newwords, $word); } return join(" ", $newwords); } It doesn't work for Irish names, etc. So keep that in mind. ---- Server IP: 69.147.83.197 Probable Submitter: 216.51.246.190 (proxied: 127.0.0.1) ---- Manual Page -- http://www.php.net/manual/en/function.mb-convert-case.php Edit -- https://master.php.net/note/edit/87704 Del: integrated -- https://master.php.net/note/delete/87704/integrated Del: useless -- https://master.php.net/note/delete/87704/useless Del: bad code -- https://master.php.net/note/delete/87704/bad+code Del: spam -- https://master.php.net/note/delete/87704/spam Del: non-english -- https://master.php.net/note/delete/87704/non-english Del: in docs -- https://master.php.net/note/delete/87704/in+docs Del: other reasons-- https://master.php.net/note/delete/87704 Reject -- https://master.php.net/note/reject/87704 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148273) next »