Home > Article > Backend Development > preg_replace改成preg_replace_callback
preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $value);
正则不怎么懂
preg_replace_callback('!s:(\d+):"(.*?)";!s', function($m) { return 's:'.strlen($m[2]).":\"$m[2]\";";}, $value);