i am trying to scan our apache log file and output only unique IP addresses. i do NOT want to use mysql. any ideas?? i can output addresses. or do a simple [array_unique]. but i am not able to do both.
...[SNIP]
// open file
$handle = fopen("/logs/access.log", "r");
// scan file into parts with separators
while ($log = fscanf($handle, "%s - - %s %s %s %s\n")) {
// while it is scanned, list variables to the parts(values)
list ($ip, $stamp1, $stamp2, $method, $url) = $log;
// input $ip to array. for the purpose of this question, i am using
// only 1 variable, ie $ip
$input = array($ip);
// create and print array_unique
$result = array_unique($input);
foreach($result as $row)
{
print"<tr><td>".$row."</td></tr>";
}
}
// close
fclose($handle);
[SNIP]...
this outputs a column with duplicate IPs, like so:
168.143.113.138
168.143.113.138
216.127.72.7
[SNIP]...
why is [array_unique] not working?? suggestions include: using the IP address as the KEY of the array, since array indexes are unique.
any ideas?? some sample code would be helpful. thanks.