note 86459 added to function.ucwords

From: Date: Mon, 20 Oct 2008 14:14:41 +0000
Subject: note 86459 added to function.ucwords
Groups: php.notes 
Request: Send a blank email to php-notes+get-145510@lists.php.net to get a copy of this message
I have looked for a work-around that would upper-case letter after an ' too. For example, ucword("o'lunney's"); would output "O'lunney's" and I wanted it to output "O'Lunney's". Here is my function: function my_ucwords($string) { $string = ucwords(strtolower($string)); $string = preg_replace_callback("/( [ a-zA-Z]{1}')([a-zA-Z0-9]{1})/s",create_function('$matches','return $matches[1].strtoupper($matches[2]);'),$string); return $string; } Hope it helps someone. ---- Server IP: 69.147.83.197 Probable Submitter: 79.114.17.176 ---- Manual Page -- http://www.php.net/manual/en/function.ucwords.php Edit -- https://master.php.net/note/edit/86459 Del: integrated -- https://master.php.net/note/delete/86459/integrated Del: useless -- https://master.php.net/note/delete/86459/useless Del: bad code -- https://master.php.net/note/delete/86459/bad+code Del: spam -- https://master.php.net/note/delete/86459/spam Del: non-english -- https://master.php.net/note/delete/86459/non-english Del: in docs -- https://master.php.net/note/delete/86459/in+docs Del: other reasons-- https://master.php.net/note/delete/86459 Reject -- https://master.php.net/note/reject/86459 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145510) next »