bcoffin Posted September 11, 2007 Share Posted September 11, 2007 If I pass an email in my GET string (such as: www.mysite.com?my_email_address@hotmail.com), I noticed that parsing the GET gives me: Array ( [my_email_address@hotmail_com] => ) What's the easiest means of changing that LAST underscore ("_") back to a period (".") ? Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 http://php.net/strrpos and http://php.net/str_replace Quote Link to comment Share on other sites More sharing options...
bcoffin Posted September 11, 2007 Author Share Posted September 11, 2007 Thanks.. That's what I'm currently using.. it's just some ugly code. No other ideas, eh? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 11, 2007 Share Posted September 11, 2007 <?php str_replace('@mysite_com','@mysite.com');?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 And you'll add that for every possible domain? BEEEEP. Wrong answer. You could use a regex but that would be even MORE complicated and ugly. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 11, 2007 Share Posted September 11, 2007 <?php $stripscore = strpos($string, "_"); $string="my_email_address@hotmail_com"; if(strpos($string,"_",$string+3)) { str_replace($stripscore,'.');} ?> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 but we missed the domains that end with only 2 letters.... Quote Link to comment Share on other sites More sharing options...
corbin Posted September 11, 2007 Share Posted September 11, 2007 You could try a weird regular expression like: ^(.*)_([a-z]+)([\._]{1}[a-z]+)$ Quote Link to comment Share on other sites More sharing options...
bcoffin Posted September 11, 2007 Author Share Posted September 11, 2007 I'm horrid at regex.. Will the one you offered work? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 WHY on earth are you trying to change the perfectly good code? Post what you have. Quote Link to comment Share on other sites More sharing options...
bcoffin Posted September 11, 2007 Author Share Posted September 11, 2007 Even though I don't understand regex, it looks so much cleaner than these if(strrchr) or if(strrpos) tests. Thanks all.. it's super now. Quote Link to comment Share on other sites More sharing options...
corbin Posted September 11, 2007 Share Posted September 11, 2007 This is a strange question, but uhhh... Why not just do: http://yoursite.com/?email=your_email@hotmail.com And then you could access it through $_GET['email'], and it would show up correctly. Quote Link to comment Share on other sites More sharing options...
corbin Posted September 11, 2007 Share Posted September 11, 2007 Oh, and yould could also try manipulating $_SERVER['QUERY_STRING']. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted September 11, 2007 Share Posted September 11, 2007 yes, my first thought was "how are you ending up with an underscore in the email address?" Quote Link to comment 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.