@ 2013-12-17T19:11:33Z <?php
echo preg_replace_callback('/([a-z])(_[a-z])/', function($u)
{
//var_dump($u);
return $u[1].ucwords(str_replace('_', '', $u[2]));
}
, 'rob_tr_yuui');
echo PHP_EOL;
echo preg_replace('/([a-z])(_[a-z])/', '$1$2', 'rob_tr_yuui');
function to_camel_case($str, $capitalise_first_char = false) {
if($capitalise_first_char) {
$str[0] = strtoupper($str[0]);
}
$func = create_function('$c', 'return strtoupper($c[1]);');
return preg_replace_callback('/_([a-z])/', $func, $str);
}
echo PHP_EOL;
echo to_camel_case('rob_tr_yuui');
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 robTrYuui
rob_tr_yuui
Fatal error: Uncaught Error: Call to undefined function create_function() in /in/QduQl:37
Stack trace:
#0 /in/QduQl(49): to_camel_case('rob_tr_yuui')
#1 {main}
thrown in /in/QduQl on line 37
Process exited with code 255 . Output for 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.25 , 7.4.27 - 7.4.33 robTrYuui
rob_tr_yuui
Deprecated: Function create_function() is deprecated in /in/QduQl on line 37
robTrYuui Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.37 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.3.32 - 7.3.33 , 7.4.26 robTrYuui
rob_tr_yuui
robTrYuui Output for 4.4.2 - 4.4.9 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 Parse error: syntax error, unexpected T_FUNCTION in /in/QduQl on line 6
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 , 5.0.0 - 5.0.5 Parse error: parse error, unexpected T_FUNCTION in /in/QduQl on line 6
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/QduQl on line 6
Process exited with code 255 . preferences:dark mode live preview
259.64 ms | 401 KiB | 366 Q