Just started
Moderator: General Moderators
Just started
Ok..I just started about a month ago. While learning this...HTML, Java, MySql and a host of other things to make my website looking good. Its doing great and I have to thank everyone for posting on this website I use this as a good resource. But I have a roadblock that I don't know what I need to do first?
I have a simple text log file from a gaming server that I need a php script to search through the file, count how many times something shows up(a particular name, or more then one actually) and tell me what it came up with. I'm pretty sure php will do this considering what I have done with it so far but can someone throw me a bone and tell me where to start?...
Oh by the way take a look at the website and see what you think....
http://www.invisiblewarriors.com
I have a simple text log file from a gaming server that I need a php script to search through the file, count how many times something shows up(a particular name, or more then one actually) and tell me what it came up with. I'm pretty sure php will do this considering what I have done with it so far but can someone throw me a bone and tell me where to start?...
Oh by the way take a look at the website and see what you think....
http://www.invisiblewarriors.com
Medal of honor allied assault. I have a server log file and need to open the file then look (search) through it..find a team members name, then count that, then keep looking for another team members name, count that etc.... till all the team members have been found or it has looked through the whole file. Then output that to a page and tell me how many times(if any) it found of each team member.
Ok first time doing anything with a file...this works
But I have approximately 30+ more names to look for in this file. What would be the easer way to write a loop program.
Code: Select all
<?php
// Open the text file
$filename = "endofday.txt";
$fp = fopen($filename,"r");
// Read the file
$end_report = fread($fp, filesize($filename));
// Define search
$needle1 = "WhereArtThou";
$needle2 = "BlackBart";
// Count the number of occurences
$num_occurs1 = substr_count($end_report, $needle1);
$num_occurs2 = substr_count($end_report, $needle2);
// Set the total number of occurences
$total1 = $num_occurs1;
$total2 = $num_occurs2;
print "WhereArtThou $total1 <br>";
print "BlackBart $total2 <br>";
fclose($fp);
?>Could creat an associative array, where each person's name is a key.
Code: Select all
<?php
// Open the text file
$filename = "endofday.txt";
$fp = fopen($filename,"r") or die("Failed!");
// Read the file
$end_report = fread($fp, filesize($filename));
// Define search
$names['BlackBart'] = 0;
$names['WhereArtThou'] = 0;
// Count the number of occurences
foreach(array_keys($names) as $value){
$names[$value] = substr_count($end_report, $value);
}
// Set the total number of occurences
foreach($names as $key=>$value) {
echo "$key: $names[$key] <br />\n";
}
fclose($fp);
?>I thought that an array might solve the problem but i kept trying to do a while statement, never thought to use foreach.
Thanks alot....that works now.....
all i have to do is an interface to be able to work it into a access script so I can have individual days and do a table layout and im done......
Thanks alot....that works now.....
all i have to do is an interface to be able to work it into a access script so I can have individual days and do a table layout and im done......
I don't want to interrupt your affords in scripting php but you might take a look at http://stats.clanfx.com/ 
Understandable and it is a nice stats program. But one of my own team members has made a server tool Called MOHAA Counter Intelligence. Basically I'm taking a log file generated by that and (hopefully) have a form that takes that log file and interprets the data , see who was on, and then output it to html. I have the output I just need to work on the form and Itll be complete.
ok I got a form down to where someone can upload a file and retrieve results from the previous scripts......Now when doing multiple files(like having 7 files for monda, tuesday, etc) do you need to upload, create a array then use the foreach to go through each file or is this not possible?...I tried just doing two and it doesnt seem to want to count either one....