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  :)

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.