ball420 Posted April 25, 2007 Share Posted April 25, 2007 i want to be able to just pull the first part of the person's email address from mydatadase to appear on the page how would i got about doin this? thanks for the input Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/ Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 <?php list($Emailalias, $Host) = explode ("@", $Email); ?> Where $Email contains the email of your user. The first part of the email adress will be stored in $Emailalias. Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238389 Share on other sites More sharing options...
sw0o0sh Posted April 25, 2007 Share Posted April 25, 2007 uhh.. isnt <?PHP $r = explode("@",$email); echo $r[0]; ?> easier to understand if he doesn't get your termonology? Explode() arrays before and after every @ in a string of text, so $r[1] would be hotmail.com or something similar. Good luck Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238399 Share on other sites More sharing options...
Mr. R Posted April 25, 2007 Share Posted April 25, 2007 what does the $host variable do? Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238404 Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 It's just my terminology, I used that name for the that specific variable. Actually provider would have been a better name . Good note swOoOsh. $Host will store everything after the '@' sign so for example hotmail.com. Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238435 Share on other sites More sharing options...
Mr. R Posted April 25, 2007 Share Posted April 25, 2007 Ohh right ok, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238441 Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 No biggie. Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238444 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 OK this was just some pratice for me but i thought i'll post it this check the email is valid and get the alias and host as a note Anzeo is better (being simpler and quicker) this does check for a valid domain name (thats name, it doesn't mean it a valid email as the domain may not exist) <?php $email = "bob_the-Builder@our-house.com"; if (eregi('([A-Z0-9._%-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})', $email, $regs)) { $EmailAlias = $regs[1]; $EmailHost= $regs[2]; } echo $EmailAlias; echo "<br />@<br />"; echo $EmailHost; ?> Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238516 Share on other sites More sharing options...
sw0o0sh Posted April 25, 2007 Share Posted April 25, 2007 I don't exactly see why he would want to "revalidate" the email if its already stored somewhere (assuming he validates it when they register >_>), and i never really heard of an email being valid with two @ symbols so the extra work is kinda unnecessary for something so simple. And thanks for the heads up on the list() function, i didnt know it existed until you said somethin :-P, though I still dont see the need of doing that if he only wants the first part from the email. Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238544 Share on other sites More sharing options...
MadTechie Posted April 25, 2007 Share Posted April 25, 2007 OK this was just some pratice for me but i thought i'll post it also you may wanna check the results when 2 @'s are used Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238551 Share on other sites More sharing options...
Anzeo Posted April 25, 2007 Share Posted April 25, 2007 And thanks for the heads up on the list() function, i didnt know it existed until you said somethin :-P, though I still dont see the need of doing that if he only wants the first part from the email. It's the easiest way to do so . You even could let out $Host, it would only store the alias then. Quote Link to comment https://forums.phpfreaks.com/topic/48668-pulling-first-word/#findComment-238570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.