Jump to content

Having a problem storing IP's to an array


STaRDoGG

Recommended Posts

Hi all,

 

Not too well versed in PHP, and I am trying to create an array that stores IP addresses, and later on I do a foreach loop on the array. I am storing them at the top of the script like this:

 

$filterIP[0] = "11.11.11.11";
$filterIP[1] = "22.22.222.2"; 

 

etc.

 

When I comment out all elements of the array except the first [0], the script runs as intended. However, when I uncomment [1] or more, I get this error: unexpected T_IS_EQUAL on the [1] line.

 

For kicks, I tried making the arrays into:

 

$filterIP[0] == "11.11.11.11";
$filterIP[1] == "22.22.222.2"; 

 

 

(Double equals signs) as a test, but then I got an error during the foreach loop.

 

Anyone have any advice?

 

Thanks  :)

 

 

There is nothing explicitly wrong with this try:

$filterIP = array('11.11.11.11', '22.22.22.22');

or if you want something more human readable try this:

$filterIP = array();
$filterIP .= '11.11.11.11';
$filterIP .= '22.22.22.22';
...

If this still does not work please post some of the surrounding code.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.