I have a large body of text in a variable called $storyText. It’s paragraphs of text in a news story.
I want to loop through an array of people in my database and see if there’s a match. Sometimes the story will be “firstname lastname”” other times it’ll be “knownas lastname” other times it’ll be first “lastname firstname”.
I already have a list of names in my array. I was going to do something like this.
Within each if statement, just a particular name arrangement. I have properties, firstname, lastname and knownas within the person object.
My question is.. what’s the best way to match each name string to something in my $storyText?
preg_match or something else?
[code]
$matchedIDs = array();
foreach($personList as $person){
if(){
…
$matchedIDs[] = $person->getID();
} elseif (){
….
$matchedIDs[] = $person->getID();
} elseif(){
….
$matchedIDs[] = $person->getID();
}
}