note 59367 added to function.ucwords

From: Date: Sun, 04 Dec 2005 22:57:29 +0000
Subject: note 59367 added to function.ucwords
Groups: php.notes 
Request: Send a blank email to php-notes+get-99564@lists.php.net to get a copy of this message
Whoa guys, tone things down a bit here. No need to loop and implode. This is a one-line solution: function ucsmart($text) { return preg_replace('/([^a-z]|^)([a-z])/e', '"$1".strtoupper("$2")', strtolower($text)); } igua's code adds a backslash in front of the first single quote for me. This doesn't alter the content in any way other than changing case. ---- Manual Page -- http://www.php.net/manual/en/function.ucwords.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59367 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59367&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59367&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99564) next »