Preg_replace with an Array

Hi There,

I am struggling too make this code work. The goal is to get rid of any of the values in array one or two. The issue I am having is array 2 is taking out parts of peoples names. The second array should only be counted if the entry is a full word.

Example1 John Doe et should = John Doe
Example2 John Doet et should = John Doet

Thank you for the help ahead of time. I am not great at PHP.

foo(); function foo() {

$text = [(Variable) parserName];
$nothing="";

$textArr = array("et al", "(Heirs, etc.)", "Guardian of", "also known as","et al sr", "et al jr");

$textArr2 = array("et", "etc", "ect","(Heirs, etc.", "(Heirs,",".", ",","Trustee", "A/K/A", "aka");



$firstArrParse= str_replace($textArr1, $nothing, $text);


$string = preg_replace('/\b$textArr2\b/', $nothing, $firstArrParse);

return trim($string);
Sponsor our Newsletter | Privacy Policy | Terms of Service