We're currently getting a preg_replace error message on our site due to deprecation.
Our code is as follows:
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data);
Any suggestions on how this can be replaced with non-deprecated code?
In this case, I found this "callback_function" that works fine:
You're using the modifiers
s
ande
. Copied directly from Deprecated feature sin PHP 5.5.x:preg_
is not deprecated. It is just/e
(as of PHP 5.5):and as
preg_replace_callback()
is almost identical topreg_replace()
with exception that it uses callback instead of replacement, update of your code should be quick homework.