3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function camelCaseToUnderscore($input) { return strtoupper(preg_replace('/(?<!^)[A-Z]/', ' $0', $input)); } echo camelCaseToUnderscore('CamelCaseForTheWin'), "\n"; echo camelCaseToUnderscore('ACar'), "\n"; echo camelCaseToUnderscore('buyACar'), "\n"; echo camelCaseToUnderscore('XML'), "\n"; echo camelCaseToUnderscore('SimpleXML'), "\n";
based on hnLEU
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0alpha1
CAMEL CASE FOR THE WIN A CAR BUY A CAR X M L SIMPLE X M L