To convert a string from CamelCase to underscore_notation in PHP, use the following code:
$my_camel_case_string = "fooBar";
$resulting_string = strtolower(preg_replace("[A-Z]", "_\$1", $my_camel_case_string));
$my_un_camel_cased_string = $resulting_string;
The code can be made into a function like this:
function un_camel_case($string){
return strtolower(preg_replace("[A-Z]", "_\$1", $string));
}
http://i.qkme.me/35hg1o.jpg