PHPRO.ORG

Here is a little helper function that is the buddy to the Underscore-To-Camel-Case function. This function does the exact opposite by taking a camelCase string and converting to under_scores.

<?php
    
/**
    *
    * Convert a camel case string to underscores (eg: camelCase becomes camel_case)
    *
    * @param    string    The string to convert
    * @return    string
    *
    */
    
function camelCaseToUnderscore$string )
    {
    
$string[0] = strtolower($string[0]);
    
$func create_function('$c''return "_" . strtolower($c[1]);');
    return 
preg_replace_callback('/([A-Z])/'$func$string);
    }
?>

Usage

<?php
    $string 
'thisIsACamelCaseString';
    echo 
camelCaseToUnderscore$string );
?>

Demonstration

this_is_a_camel_case_string