Re: Do I Need preg_match?

From: Date: Wed, 09 Aug 2000 21:53:34 +0000
Subject: Re: Do I Need preg_match?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11001@lists.php.net to get a copy of this message
"Kurt Boyer" <kboyer@matchlogic.com> wrote in message news:5FE9B713CCCDD311A03400508B8B30130269988D@bdr-xcln.is.matchlogic.com... > > In converting the following PERL regular expression to equivalent PHP code, > is the preg_match function the way to go, or is there a way to do it with > ereg? > > if($COUNTRY =~ /AR|AU|BD|BN|BG|GW|NA|PH|SG|ZA|TN|VE/) { return; } You can do it with either one. Do note that the preg* functions have a reputation for being faster than their ereg equivalents. Also, if this code is going to be executed often (e.g. in a loop) it might be faster to do something like this: $Countries = array('AR', 'AU', 'BD', 'BN', 'BG', 'GW', 'NA', 'PH', 'SG', 'ZA', 'TN', 'VE'); // do looping stuff here if (in_array($Countries, $Country)) { return; }

« previous php.general (#11001) next »