View Full Version : Need help with a script

09-30-2006, 11:43 PM
Hello, I am a beginner in PHP.

I would like help in extracting IP addresses from a html text page.


eg there are hundreds of IP addresses, but I only want to extract ones that are displayed more than once and display them on a separate output file.

Can anyone help me out.


10-01-2006, 12:14 AM
The way I'd do it is load the file into an array with the file() (http://us2.php.net/manual/en/function.file.php) function.

Then, loop through the array. Use a regular expression (http://us2.php.net/manual/en/ref.pcre.php) on each array element to isolate the IP address in the line and dump that into another array to create an array of IP addresses.

Then, I'd use the array_unique() (http://us2.php.net/manual/en/function.array-unique.php) function on your IP array.