$comment = preg_replace('~\b(\w)(\w+)~e', '"$1".strtolower("$2")', $comment); "PHP message: PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in
can somebody suggest me al alternative for this preg_replace? Thanks.
Try reading the error message; an alternative is mentioned there.
I have read it but I don't know how to modify it
$comment = preg_replace_callback('~\b(\w)(\w+)~e', '"$1".strtolower("$2")', $comment); preg_replace_callback(): Requires argument 2, '"$1".strtolower("$2")', to be a valid callback in
$comment = preg_replace_callback( '~\b(\w)(\w+)~' // no more "e" modifier function($matches) { // can use an in-line anonymous function return($matches[1].strtolower($matches[2])); }, $comment );
thank you but it this produces an error:
unexpected 'function' (T_FUNCTION), expecting ',' or '
Looks like I left out a comma after the regex string.