0

I am using rockmongo in php application, it throws error message like

"Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\rockmongo\rock.php on line 457"

function rock_name_to_java($name) {
    $name = preg_replace("/_([a-zA-Z])/e", "strtoupper('\\1')", $name);
    return $name;
 }

Please help me !!!

Wasi Ahmad
  • 35,739
  • 32
  • 114
  • 161
Nida
  • 1,672
  • 3
  • 35
  • 68

2 Answers2

0
 function rock_name_to_java($name) {
   return preg_replace("/\/_([a-zA-Z])\/e/", "strtoupper(\\1)", $name);
 }

How about this

Amit
  • 451
  • 1
  • 6
  • 19
  • Now it throws "preg_replace_callback(): Requires argument 2, 'strtoupper('\1')', to be a valid callback in C:\xampp\htdocs\rockmongo\rock.php on line 458" – Nida Apr 14 '17 at 06:54
  • It is working when i tested it. Please give me your input $name – Amit Apr 14 '17 at 07:14
0

Well, it's because preg_replace() has been deprecated and will likely be removed from future versions.

Instead, do this. *Note, I didn't test it.

$name = preg_replace_callback(
   "/_([a-zA-Z])/e",
   function ($matches) {
     return strtoupper($matches[0]);
},
 $name
);
Difster
  • 3,264
  • 2
  • 22
  • 32