How to convert PascalCase to pascal_case?
If I had: $string = "PascalCase"; I need "pascal_case" Does PHP offer a function for this purpose? Try this on for size: $tests = array( 'simpleTest' => 'simple_test', 'easy' => 'easy', 'HTML' => 'html', 'simpleXML' => 'simple_xml', 'PDFLoad' => 'pdf_load', 'startMIDDLELast' => 'start_middle_last', 'AString' => 'a_string', 'Some4Numbers234' => 'some4_numbers234', 'TEST123String' => 'test123_string', ); foreach ($tests as $test => $result) { $output = from_camel_case($test); if ($output === $result) { echo "Pass: $test => $result\n"; } else { echo "Fail: $test => $result [$output]\n"; } }