hello alex,
i hope it works like this:
if($myFile = fopen("16.log", "r"))
{
while(!feof($myFile))
{
$myLine = fgets($myFile, 255);
$logData = split('[\t ]+', $myLine);
$gameName[] = $logData[3]; //store in array
}
fclose($myFile);
}
$result=do_array_unique($gameName);
// now $result should contain only unique
// values...
#####################
function do_array_unique($arr)
{
$newarr[]="";
$count=count($arr);
for($i=0,$nc=0;$i<$count;$i++)
{
$val=$arr[$i];
if(!in_array($val,$newarr))
{
$newarr[$nc++]=$val;
}
}
return $newarr;
}
(i once wrote this function because php4-function 'array_unique' seemed not to work properly...)
hth
chris
Alex Ressi wrote:
I am writting a script to parse a log file. A portion of the log file looks like this...
17/01/02 15:29:09:030 N chuckie 80.4.113.39
I am interested in the "chuckie" field in the file. I have used the following code to successfully make each line into a string and then split the string into an array....
if($myFile = fopen("16.log", "r"))
{
while(!feof($myFile))
{
$myLine = fgets($myFile, 255);
$logData = split('[\t ]+', $myLine);
$gameName = $logData[3];
}
fclose($myFile);
}
That works fine and $gameName accesses the info I want. I want to check if the $gameName field is unique and store only unique values in an array, so that I can access them. I haven't been able to figure it out though. Any help would be appreciated.