Re: Regex in PHP

From: Date: Wed, 04 Jun 2008 17:11:07 +0000
Subject: Re: Regex in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-275022@lists.php.net to get a copy of this message
I can't find any good reason for regex in this case. you can try to split it with explode / stristr / create a function by your own which goes over the string and check when a @ is catched, something like: function GetDomainName ($a) { $returnDomain = ""; $beigale = false; for ($i = 0; $i < strlen($a) && !$beigale; $i++) if ($a[$i] == '@') { for ($z = ($i+1); $z < strlen($a); $z++) $returnDomain .= $a[$z]; $beigale = true; } return $returnDomain; } (there is probably a better way to do this - this is just what came up at my mind right now..) On 04/06/2008, VamVan <vamseevan@gmail.com> wrote: > > Hello All, > > For example I have these email addressess - > > xxxx@yahoo.com > xxxx@hotmail.com > xxxx@gmail.com > > What would be my PHP function[Regular expression[ to that can give me some > thing like > > yahoo.com > hotmail.com > gmail.com > > Thanks >

« previous php.general (#275022) next »