正規表現を使用してリストから名前を除外するにはどうすればよいですか?
データ:
$subject=
"Damon Carson Stovall,
Bret Roman Mikulak,
Jack Filiberto Quirke,
Elroy Forrest Jarnagin,
Ulysses Wiley Cregger,
Brent Greg Jonah,
Bret Armand Daylong,
Ned Numbers Vandell,
Bret Alden Cutlip,
Bret Chung Markie,";
正規表現:
// Select anyone with the first name of Bret
$pattern = "/Bret /";
私の現在の解決策:
// Loop through & Skip any line that matches Bret.
$subject_array = explode(",",$subject);
foreach($subject_array as $line)
if(!preg_match($pattern, $line))
echo "$line<br>";