note 102939 deleted from function.strtoupper by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:08:12 +0000 |
| Subject: | note 102939 deleted from function.strtoupper by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189710@lists.php.net to get a copy of this message | ||
Note Submitter: christoph dot hochstrasser at gmail dot com
----
For beginners: here is the most simple Camelize function for PHP. It converts underscore or dash
separated strings to camelCase, optionally with a Parameter to convert them to PascalCase (often
needed for Class names).
<?php
function camelize($string, $pascalCase = false)
{
$string = str_replace(array('-', '_'), ' ', $string);
$string = ucwords($string);
$string = str_replace(' ', '', $string);
if (!$pascalCase) {
return lcfirst($string);
}
return $string;
}
?>