- array_map: documentation ( source)
- preg_replace_callback: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
- lcfirst: documentation ( source)
- strtolower: documentation ( source)
- ucfirst: documentation ( source)
<?php
function v1($value) {
return implode(array_map(function($value) { return ucfirst($value); }, explode('_', $value)));
}
function v2($value) {
return preg_replace_callback('/([A-Z])/', function($char) { return '_'.strtolower($char[1]); }, lcfirst($value));
}
for($x = 0; $x < 10000; $x++){
$foo = v2('foo_bar_baz_bee');
}