|
Posted by Michael Fesser on 01/02/08 21:37
..oO(Poster)
>I am trying to pass an array of titles through an array of "keywords". The
>$filter_test will later be replaced with real data coming from another
>source, I am testing it this way to save time.
>
>I have this:
>[...]
>
>Why does it only match on the first, then no match on the other identical
>entries ? Please go easy, this is my attempt at both arrays and preg_match.
$filter_test = array("Thundarr the Barbarian", "Cash and Treasure",
"Welcome
Back Kotter", "Amazing Race", "The Waltons");
$filter_title = array("Thundarr", "Cash", "Kotter");
foreach($filter_test as $valtest) {
foreach($filter_title as $val) {
if (preg_match("/\b$val\b/i", $valtest)) {
echo "MATCH '$val' ON '$valtest'\n";
} else {
echo "NO MATCH '$val' ON '$valtest'\n";
}
}
}
Now clearer?
Micha
[Back to original message]
|