note 75324 added to function.ucwords

From: Date: Wed, 23 May 2007 23:27:27 +0000
Subject: note 75324 added to function.ucwords
Groups: php.notes 
Request: Send a blank email to php-notes+get-126857@lists.php.net to get a copy of this message
To use ucwords with an exception: <?php function ucwordss($str, $exceptions) { $out = ""; foreach (explode(" ", $str) as $word) { $out .= (!in_array($word, $exceptions)) ? strtoupper($word{0}) . substr($word, 1) . " " : $word . " "; } return rtrim($out); } ?> For example: <?php $string = "my cat is going to the vet"; $ignore = array("is", "to", "the"); echo ucwordss($string, $ignore); // My Cat is Going to the Vet ?> ---- Server IP: 194.145.210.3 Probable Submitter: 86.136.187.224 ---- Manual Page -- http://www.php.net/manual/en/function.ucwords.php Edit -- https://master.php.net/note/edit/75324 Del: integrated -- https://master.php.net/note/delete/75324/integrated Del: useless -- https://master.php.net/note/delete/75324/useless Del: bad code -- https://master.php.net/note/delete/75324/bad+code Del: spam -- https://master.php.net/note/delete/75324/spam Del: non-english -- https://master.php.net/note/delete/75324/non-english Del: in docs -- https://master.php.net/note/delete/75324/in+docs Del: other reasons-- https://master.php.net/note/delete/75324 Reject -- https://master.php.net/note/reject/75324 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126857) next »