I have this script here that parses a NAME and comes out with the correct way to display the name and salutation.
$nameStr = $row1["CUSTOMERNAME"];
if(strpos($nameStr, ','))
{
list($firstPart,$secondPart)=explode(',', $nameStr);
$customername2 = "$secondPart $firstPart";
}else{
// Get only the first name, and leave the rest.
$customername2 = $row1["CUSTOMERNAME"];
}
$name = $row1["CUSTOMERNAME"];
if(strpos($name, ','))
{
// We'll extract just the first name
$names = explode(",", $name);
// And remove trailing spaces
$name = trim($names[1]);
}
if(strpos($name, ' '))
{
// Get only the first name, and leave the rest.
$name = substr($name, 0, strpos($name, ' '));
}
Here are some of the variables that go into that parsing script.
SOUTH SIDE ELECTRIC INC
SPALDING, DAVID ANDREW
STIEF, BURDETTE C
STIER TRANSPORTATION SERVICES
VALLEY PLUMBING CO
ALAN MALZ
ALVIRA HAUS
ANDREW WEINANDT
ANGELA HENNEN
ANTHONY KRAUTKREMER
ANTHONY SCHMIDT
BARBARA MINAR
My problem comes in when there is a business like "SOUTH SIDE ELECTRIC INC", the salutation comes up with Dear INC, when it should read Dear SOUTH SIDE ELECTRIC INC, . The names work fine "ALAN MALZ" comes up with Dear ALAN, . and "STIEF, BURDETTE C" comes up with Dear BURDETTE, .
I don't even know if this is possible or not, I have no other identifiers in there for Business's, so I can't decifer it that way. Let me know if you have any thoughts, thanks in advance.