Page 1 of 1
Format string
Posted: Wed Nov 22, 2006 10:19 am
by JimiH
Hello
I have a variable $ENGINEER which contains a string
Example - SMITH BILL
I would like to format this string into the following
bill.smith@somewhere.com
Hope someone can help
Geoff
Posted: Wed Nov 22, 2006 10:27 am
by JayBird
Code: Select all
$ENGINEER = "SMITH BILL";
$nameParts = explode(' ', strtolower($ENGINEER));
$email = $nameParts[1].'.'.$nameParts[0].'@somewhere.com';
Posted: Wed Nov 22, 2006 5:21 pm
by JimiH
Thanks Jaybird
That worked
The reason I had to change to the full email address is that the mail() function in
PHP didn't reconise "SMITH BOB" as a valid email address, however we use exchange
so "SMITH BOB" is fine in Outlook as it looks up the full email in the Global address book.
I'm nearly at the end of the project and assumed incorrectly that producing the names in the
"SMITH BOB" format and trying to use them in the mail() function would work.
I'm left with two varables
$SALESMAN
$ENGINEER
And an Aaray
$Project_members
Which all have the names in the "SMITH BOB" format which I need to convert into the full email address.
Is there anyway round this?
I suppose I could add an email fieild to the tables in the DB.
Thanks
Geoff
Posted: Wed Nov 22, 2006 5:30 pm
by John Cartwright
JayBird wrote:Code: Select all
$ENGINEER = "SMITH BILL";
$nameParts = explode(' ', strtolower($ENGINEER));
$email = $nameParts[1].'.'.$nameParts[0].'@somewhere.com';
Code: Select all
$email = str_replace(' ', '.', strtolower($ENGINEER)).'@somewhere.com';
Which all have the names in the "SMITH BOB" format which I need to convert into the full email address.
I am not sure what you are asking anymore..
I suppose I could add an email field to the tables in the DB.
This is ideal, yes.
Posted: Wed Nov 22, 2006 5:42 pm
by JimiH
I am not sure what you are asking anymore..
Hi
I know I'm confusing myself!!
Basicly I have a bunch of strings and one array with names in them, these are in the format "LAST NAME, FIRSTNAME" When I try to use the strings with the mail() function it gets rejected, it wants the full email address
firstname.lastname@somewhere.com
So either I add a email field or I convert the strings into full email addys.
Just as a quick question
What if there where more names in the string upto 8 maybe?
Example
$ENGINEER = SMITH BOB JONES TOM HENDRIX JIMI
Thanks
Geoff