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
Format string
Moderator: General Moderators
Code: Select all
$ENGINEER = "SMITH BILL";
$nameParts = explode(' ', strtolower($ENGINEER));
$email = $nameParts[1].'.'.$nameParts[0].'@somewhere.com';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
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
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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';I am not sure what you are asking anymore..Which all have the names in the "SMITH BOB" format which I need to convert into the full email address.
This is ideal, yes.I suppose I could add an email field to the tables in the DB.
HiI am not sure what you are asking anymore..
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