ionicle Posted July 16, 2013 Share Posted July 16, 2013 I've got a list of IP ranges, each one on a new line, in the following format: x.x.x.x-x.x.x.x I would like to enclose each IP range within a <deny></deny> tag automatically. How would I go with that? Quote Link to comment Share on other sites More sharing options...
kicken Posted July 16, 2013 Share Posted July 16, 2013 foreach ($ipRangeList as $range){ echo '<deny>'.$range.'</deny>'; } Quote Link to comment Share on other sites More sharing options...
ionicle Posted July 16, 2013 Author Share Posted July 16, 2013 (edited) <?php // Open the file $fp = @fopen("koch.txt", 'r'); // Add each line to an array if ($fp) { $array = explode("\r\n", fread($fp, filesize("koch.txt"))); } foreach ($array as $range){ echo "<deny>".$range."</deny>"; } ?> It's not working. The two lines contain the following values: x.x.x.x x.x.x.x When I run the script, all I get is: "x.x.x.xx.x.x.x" ( the two values from the two lines glued together, with absolutely no "deny" tags ) What am I missing? Edited July 16, 2013 by ionicle Quote Link to comment Share on other sites More sharing options...
requinix Posted July 17, 2013 Share Posted July 17, 2013 What am I missing?Do a View Source of the page. Quote Link to comment Share on other sites More sharing options...
ionicle Posted July 17, 2013 Author Share Posted July 17, 2013 Gee... thank you. Had no idea <deny> was actually a valid HTML tag, I needed it for something else... Quote Link to comment Share on other sites More sharing options...
requinix Posted July 17, 2013 Share Posted July 17, 2013 It's not. Doesn't have to be valid to be "hidden" from view. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.