RE: [PHP-DB] "The" Debacle
| From: | Adam Royle | Date: | Mon, 25 Feb 2002 08:32:15 +0000 |
| Subject: | RE: [PHP-DB] "The" Debacle | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17252@lists.php.net to get a copy of this message | ||
To make sure that other names are not interfered with, I would refine what you're doing.
ie. "Theater Nuts" would become "ater Nuts, The"
obviously this is not acceptable...
so you would do something like this...
//does it begin with 'The '?
$name_start = substr($band_name, 0, 3)
if ($name_start=="The ")
{
//remove the word 'The' and following space from the beginning of the
string
$band_name = str_replace('The ', '', $band_name) ;
// add ', The ' to the end of the name
$band_name .= ", The";
}
When you add the data //does it begin with 'The '? $name_start = substr($band_name, 0, 2) if ($name_start=="The") { //remove the word 'The' and following space from the beginning of the string str_replace('The ', '', $band_name) ; //add ', The 'to the end of the name $band_name=$band_name.', The'; } You might want something more sophisticated if The with a capital is found in the middle of names, but hope this is a start Peter