0

I have a function which I'm not entirely sure how to convert to get it working with PHP 7.2:

static function toCamelCaseFromUnderscore($str) {
    $func = create_function('$c', 'return strtoupper($c[1]);');
    return preg_replace_callback('/_([a-z])/', $func, $str);
}
Michelle
  • 113
  • 4
  • 13
  • 1
    There are many examples in the doc. Can you please post what you tried as well as the error message? – Rotimi Dec 04 '18 at 15:47
  • Possible duplicate of [PHP 7.2 Function create\_function() is deprecated](https://stackoverflow.com/questions/48161526/php-7-2-function-create-function-is-deprecated) – Tomas Votruba Dec 18 '18 at 01:15
  • There is might help [Function create_function() is Deprecated in PHP 7.2 - How to Migrate?](https://www.tomasvotruba.cz/blog/2018/12/17/function-create-function-is-deprecated-in-php-72-how-to-migrate/) – Tomas Votruba Dec 18 '18 at 01:18

1 Answers1

0

Although I agree with the comments, the examples on PHP.net are more then clear, for sake of closing this

static function toCamelCaseFromUnderscore($str) {
    return preg_replace_callback('/_([a-z])/', function($c){
         return strtoupper($c[1]);
    }, $str);
}
DarkMukke
  • 2,469
  • 1
  • 23
  • 31