Mmm

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
lizzardnub
Forum Newbie
Posts: 3
Joined: Sat Jun 24, 2006 3:19 pm

Mmm

Post by lizzardnub »

Ok, so now that I was shown how to run the search against the text file, I'm left with php output:

[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";
but no joy. So this is where I stand

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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

#1 Please use more descriptive titles.. "mmm" tells me nothing
#2 Why did you start another thread?
#3 Start using [syntax=php][/syntax] tags please.

Topic Locked.
Locked