3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function camelCaseToUnderscore($input) { return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input)); } echo camelCaseToUnderscore('caseStudy'), "\n"; echo camelCaseToUnderscore('News'), "\n"; echo camelCaseToUnderscore('BuyACar'), "\n"; echo camelCaseToUnderscore('XML'), "\n"; echo camelCaseToUnderscore('SimpleXML'), "\n";
based on J1eMO
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
case_study news buy_a_car x_m_l simple_x_m_l