note 49304 added to function.ucwords
| From: | arjini at gmail dot com | Date: | Sun, 23 Jan 2005 20:20:55 +0000 |
| Subject: | note 49304 added to function.ucwords | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83824@lists.php.net to get a copy of this message | ||
Not so much ucwords() related as it is capital letter related. I often use camel casing (as do
wikis), and I needed a reason to reverse the camel casing.
function unCamelCase($str){
$bits = preg_split('/([A-Z])/',$str,false,PREG_SPLIT_DELIM_CAPTURE);
$a = array();
array_shift($bits);
for($i = 0; $i < count($bits); ++$i)
if($i%2)
$a[] = $bits[$i - 1].$bits[$i];
return $a;
}
print_r(unCamelCase('MyFancyCamelCasedWord'));
Array
(
[0] => My
[1] => Fancy
[2] => Camel
[3] => Cased
[4] => Word
)
----
Manual Page -- http://www.php.net/manual/en/function.ucwords.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49304
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49304&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49304&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49304&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49304&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49304&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49304&report=yes
Search -- http://master.php.net/manage/user-notes.php