|
Posted by Ed on 10/10/53 11:24
Max wrote:
> Is there a way to separate text in an ereg statement so that it is checked
> against separately?
>
> In other words, I've got the following:
>
> $domains = "domain1.com domain2.com domain3.com";
>
> if (ereg($domains, $variable)) do whatever...
>
> Is there any separator that I can place in between the various domains, so
> that the ereg statement will check if any of the domains is in $variable? As
> is, it checks the entire string with the spaces.
>
> I know I can explode $domains, and have multiple ereg checks in the
> statement like if ereg($domains[0],$variable) || ereg($domains[1])...etc,
> but I'm looking to avoid this so I can have an infinite number of domains.
Hi there,
Use explode() in combination with in_array()...
if (in_array($variable, explode(" ", $domains))) {
// Do something
}
Or switch your ereg() statement around...
if (ereg($variable, $domains)) {
// do something
}
Ed
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
[Back to original message]
|