Home > Backend Development > PHP Tutorial > preg_replace改成preg_replace_callback

preg_replace改成preg_replace_callback

WBOY
Release: 2016-06-23 13:25:03
Original
1145 people have browsed it

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);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template