3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function snakeToCamel($string) { $words = explode('_', $string); $camel = ''; foreach ($words as $word) { $camel .= ucfirst($word); } return $camel; } /** * underdash_separated -> camelCase. * @param string * @return string */ function underdashToCamel($s) { $s = strtolower($s); $s = preg_replace('#_(?=[a-z])#', ' ', $s); $s = substr(ucwords('x' . $s), 1); $s = str_replace(' ', '', $s); return $s; } echo snakeToCamel("ahoj_vole_todle_1_je_PECKE__") . "\n"; echo underdashToCamel("ahoj_vole_todle_1_je_PECKE__") . "\n";
Output for 4.3.0 - 7.2.0
AhojVoleTodle1JePECKE ahojVoleTodle_1JePecke__