时间:2021-07-01 10:21:17 帮助过:23人阅读
$s = 'aaaa ';
bbbb
cccc
dddd
echo preg_replace('/
\w+/', '', $s, 2);
aaaa
dddd
echo preg_replace('/
[^<]+/', '', $s, 2);
echo preg_replace('/\(.+?\)/', '', $s);
echo preg_replace_callback('/
[^<]+/', 'foo', $s, 2);
function foo($m){
return strpos($m[0], '(') !== false ? preg_replace('/\(.+?\)/','',$m[0]) : '';
}