我有点卡在这里,我做了一些预编码来查找任何 11 位数字,但我不知道如何使用找到/匹配到像"preg - time()"这样的函数
提醒一下,这 11 位数字可能会被多次找到,因此应该能够在其中任何一个上使用该功能,也许是数组上的循环或其他任何东西?
"#d{11}#" - Quick example on the preg i might will use.
帮助!
使用 preg_replace_callback
使用自定义函数对每个匹配项进行更改。
function your_custom_function($matches){
$match = $matches[0];
// Do something with $match
return $match;
}
$string = preg_replace_callback(
"#d{11}#",
"your_custom_function",
$string
);
preg_replace会自动替换所有参数,preg_match_all 会给你第三个参数中的所有匹配项。
preg_match("/d{11}/", "Quick example on the preg I might will use", $matches);
print_r($matches);