Re: set multiple variables
| From: | Paul Bissex | Date: | Fri, 01 Oct 2004 21:51:41 +0000 |
| Subject: | Re: set multiple variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198462@lists.php.net to get a copy of this message | ||
On Fri, 1 Oct 2004 17:38:31 -0400, Joe Szilagyi <js@axxs.net> wrote:
> Hi, I have this working:
>
> if ($REMOTE_ADDR == "212.3.54.65") {
> header("Location:
> http://www.google.com/search?&q=huzzah");
> Redirect browser
> exit;
> }
>
> But I want to specify multiple IPs. What's the best recommended way for
> doing that?
>
Build an array and use in_array():
$redirect_me = array ('212.3.54.65', '127.0.0.1', '192'168.0.1');
if (in_array ($_SERVER['REMOTE_ADDR'], $redirect_me))
{
header ("Location: ...");
exit;
}
If the addresses you are targeting are ranges in CIDR format (e.g.
192.168.0.0/24), take a look at the PEAR package Net_IPv4.
pb
--
paul bissex, e-scribe.com -- database-driven web development
413.585.8095
69.55.225.29
01061-0847
72°39'71"W 42°19'42"N