Hello everyone,
I am working on a page which extracts the person's first and last name from a database as: "Smith, John".
I had some unsual last names like "van Berggen" and I have managed to get the php code working for those:
$lastName_temp = strtolower($data_array[$i][1]);
$string_part_found = 0;
$pos = strpos($lastName_temp,"van ");
if($pos === 0) {
$lastName_temp = substr($lastName_temp,4);
$lastName_temp = "van ".ucfirst($lastName_temp);
$string_part_found = 1;
}
My challenge is now to ensure the few "odd" first names are rendered correctly. For example: Joe W. Smith, or Tim W.A. Luw Nilly
So I tried a variation of the code I used for the last name:
$firstName_temp = strtolower($data_array[$i][0]);
$pos = strpos($firstName_temp," s");
if($pos === 0) {
$firstName_temp = substr($firstName_temp,3);
$firstName_temp = " S".ucfirst($firstName_temp);
$string_part_found = 1;
}
I know the the first name's variable is = 0. But, no luck. No change at all is visible. I really thought it would work but somehow I am missing some part. That is where I need the help.
I even tried the straight forward replace:
$firstName_temp = str_ireplace(" s.", " S.", $firstName_temp);
but that also hasn't worked.
For the short term I just need to change these two names.
Any ideas. Many thanks!
Joey