时间:2021-07-01 10:21:17 帮助过:6人阅读
$s = 'ssssssssgsdfasdasdasdasdjlkjhkjhalkasdasdjsdkajshdasdaklsjdasdhkjashgdaklsh';$t = 'ssssssssgsdfasdjlkjhkjhalkjsdkajshdaklsjdhkjashgdaklsh';$s = preg_replace_callback('/asd/', function($r) { static $n = 0; return ! $n++ ? $r[0] : ''; }, $s);var_dump($s == $t);bool(true)
一天没时间,非常非常感谢版主,对,就是这个效果,原来还有preg_replace_callback这么好用的东西,preg_replace是不是没这个功能呀?版主