note 81662 added to function.strtoupper
| From: | jesdisciple at gmail dot com | Date: | Sun, 09 Mar 2008 01:02:40 +0000 |
| Subject: | note 81662 added to function.strtoupper | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136850@lists.php.net to get a copy of this message | ||
This function takes a space-delimited list of words and returns it as one camelcase word.
<?php
function strtocamel($str){
$str = explode(' ', strtolower($str));
for($i = 1; $i < count($str); $i++){
$str[$i] = strtoupper(substr($str[$i], 0, 1)) . substr($str[$i], 1);
}
return implode('', $str);
}
?>
Example:
<?php
echo strtocamel('Str tO CAMEL');
?>
This will output 'strToCamel'. To also make the first letter uppercase, change '$i =
1' to '$i = 0'.
----
Server IP: 64.71.164.2
Probable Submitter: 72.251.10.144
----
Manual Page -- http://www.php.net/manual/en/function.strtoupper.php
Edit -- https://master.php.net/note/edit/81662
Del: integrated -- https://master.php.net/note/delete/81662/integrated
Del: useless -- https://master.php.net/note/delete/81662/useless
Del: bad code -- https://master.php.net/note/delete/81662/bad+code
Del: spam -- https://master.php.net/note/delete/81662/spam
Del: non-english -- https://master.php.net/note/delete/81662/non-english
Del: in docs -- https://master.php.net/note/delete/81662/in+docs
Del: other reasons-- https://master.php.net/note/delete/81662
Reject -- https://master.php.net/note/reject/81662
Search -- https://master.php.net/manage/user-notes.php