[13.249.161.18] 23-06-2006 05:10 [localhost] installed blahblah crap on [8.46.176.244] 23-06-2006 05:10 [localhost] logged in to [8.46.176.244]
instead of nice orderly [ip.ip.ip.ip], [localhost], [ip.ip.ip,ip]. After reading up on it a bit I'm assuming this because search strings are inherently greedy. I tried using the >U PCRE modifier I read about at http://www.pcworld.idg.com.au
like so
Code: Select all
$pat = "<\[.*\]>U";Code: Select all
<?
$str = file_get_contents( "log/log.txt");
$pat = "\[.*\]";
$regs = array();
if(ereg($pat,$str,$regs))
{
echo "match: {$regs[0]}\n";
}
?>The end goal of this little project is to extract a bunch of IP's that are enclosed in brackets out of a text file and put them into a mysql database. I'm hoping to get only one instance of each IP address with the duplicates in the .txt file incrementing some sort of counter next to the IP.