marexforex
marexforex

Reputation: 1

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback

I can not fix this error:

$match[1] = preg_replace('/(?<=^|[a-z])./e', 'strtoupper("\0")', strtolower(trim($match[1])));

How to change it?

Upvotes: 0

Views: 331

Answers (1)

Philipp
Philipp

Reputation: 15629

You should read the manual. The e modifier is deprecated and will be removed in further versions. Just use preg_replace_callback (the message told you..)

$match[1] = preg_replace_callback('/(?<=^|[a-z])./', function($m) {
    return strtoupper($m[0]);
}, strtolower(trim($match[1])));

Upvotes: 5

Related Questions