私はちょっとここで立ち往生しています。11桁の数字を見つけるためにいくつかのpregコーディングを行いましたが、「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は3番目のパラメーターのすべての一致を提供します。
preg_match("/\d{11}/", "Quick example on the preg I might will use", $matches);
print_r($matches);