note 100673 added to function.ucwords

From: Date: Fri, 29 Oct 2010 10:17:39 +0000
Subject: note 100673 added to function.ucwords
Groups: php.notes 
Request: Send a blank email to php-notes+get-173591@lists.php.net to get a copy of this message
Here is a function that make the words prettier: <? function correct_words($s) { $a = explode(" ", $s); foreach($a as $id => $t) { $low = false; for($i = 0, $strlen = mb_strlen($t); $i <= $strlen; $i++) { if($low) { $t[$i] = mb_strtolower($t[$i]); } if(mb_ereg_match("[A-Z]", $t[$i])) { $low = true; } } $a[$id] = $t; } foreach($a as $x) { $r .= $x . " "; } return(trim($r)); } echo(correct_words("BIGWORD Correct Word smallword")); ?> Output: Bigword Correct Word smallword ---- Server IP: 212.124.37.9 Probable Submitter: 91.40.133.90 ---- Manual Page -- http://www.php.net/manual/en/function.ucwords.php Edit -- https://master.php.net/note/edit/100673 Del: integrated -- https://master.php.net/note/delete/100673/integrated Del: useless -- https://master.php.net/note/delete/100673/useless Del: bad code -- https://master.php.net/note/delete/100673/bad+code Del: spam -- https://master.php.net/note/delete/100673/spam Del: non-english -- https://master.php.net/note/delete/100673/non-english Del: in docs -- https://master.php.net/note/delete/100673/in+docs Del: other reasons-- https://master.php.net/note/delete/100673 Reject -- https://master.php.net/note/reject/100673 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173591) next »