STaRDoGG Posted July 17, 2008 Share Posted July 17, 2008 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 https://forums.phpfreaks.com/topic/115192-having-a-problem-storing-ips-to-an-array/ Share on other sites More sharing options...
unkwntech Posted July 17, 2008 Share Posted July 17, 2008 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 https://forums.phpfreaks.com/topic/115192-having-a-problem-storing-ips-to-an-array/#findComment-592300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.