[eluser]tinawina[/eluser]
I have a site that archives research reports. We store the titles so that any title starting with "The", "An", or "A" is reformatted with those words at the end. Example:
"An Annotated Study" => becomes => "Annotated Study, An"
Here's the code used to make this change:
Code:
$title = "An Annotated Study";
if ( eregi("^[An ]{3}", $title) ) {
$title2 = eregi_replace ("^[An ]{3}", "", $title);
$title = eregi_replace ($title2, $dtitle2 . ", An", $title2);
}
echo $title; // echoes "Annotated Study, An" which is correct.
When this is run the first time, all is well and we end up with the correct title. However, if this is run on this reformatted title a second time we get:
"notated Study, An, An"
Why isn't the initial eregi picking up on the required space and required 3 characters? I've tried this with preg_match as well, same thing happens.
Any help is much appreciated. Thanks!