Forum Moderators: coopster
I wrote a short function to create your own Camel Case
<?php
// transform any number of words and spaces
// in a Camel Case string (useful for URL for example)$str= "make camel case url";
function MakeCamelCase($str)
{
$upper=ucwords($str);
$str=str_replace(' ', '', $upper);return $str;
}
$str=MakeCamelCase($str);
echo"new str $str";?>
Have fun!
Isn't camelCasing different than PascalCasing?
According to Wikipedia [en.wikipedia.org]:
Some people and organizations use the term camelCase only for lowerCamelCase, and refer to UpperCamelCase as PascalCase. In some contexts, however, the term CamelCase does not discriminate between the two.
The first two references give some insight. Here nor there, henry0's example would be UpperCamelCase, or PascalCase. I've taken the liberty to offer a lowerCamelCase function to add to the arsenal :)
function makeLowerCamelCase($str)
{
return preg_replace("/\s+([a-z])/ie", 'strtoupper("$1")', trim($str));
}