PHP CamelCase extension
by Lee Parker
This is a PHP extension that provides a simple function to convert strings into CamelCase.
Build:
phpize
./configure --enable-camel-case
make
Test:
make test
php -d extension="./modules/camel_case.so" compare.php
string camel_case(string $string, string $separator = '_', boolean $lowerCaseFirst = false);
Parameters:
- $string - The input string
- $separator - The separator to identify the word breaks. Defaults to '_'.
- $lowerCaseFirst - Determines if the first character should be lower case instead of upper case. Defaults to false.
Returns the newly formatted string or NULL
.
echo camel_case("camel_case_me");
CamelCaseMe
echo camel_case("camel-case-me", '-');
CamelCaseMe
echo camel_case("camel_case_me", '_', true);
camelCaseMe