Jump to content

lfc_lad

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lfc_lad's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I done more searching on google... I came across this which, i understand a bit more than the above. <?php $total = 0; $fin = @fopen("num.txt", "r"); if ($fin) { while (!feof($fin)) { $buffer = fgets($fin); if (preg_match('/got a break of "(\d+)"/',$buffer,$matched)) $total += $matched['1']; else continue; } fclose($fin); print $total; } I guess that would show the total amount ??? , if it works. I am currently at work, so unable to test it. If i can get that to show the total of all the numbers after 'got a break of' then i can easily re write it to calculate average. Would the above be a better method for a newbie to use?
  2. Thanks, but i assume where you have Put dots in the code example i would need to put some stuff in it? Sorry for bein a noob lol. I only know the basics.
  3. Hi guys, I am a sort of newbie, so be nice I have a txt file with some data in it, Which contains numbers and text. The format of the data is as such: 20:54 Sun 28/06/09 Arcade - lfc_lad got a break of 55 20:21 Sun 28/06/09 Regular - lfc_lad got a break of 58 I managed to search the data for the occurance of a / and delete the line if it occurred. So now the format is Arcade - lfc_lad got a break of 55 Regular - lfc_lad got a break of 58 The data could be numerous multiple lines. All i want to do now, Is read all the numbers and calculate the average of these numbers which then gets displayed. The format will always be: (game) - (player) got a break of (break) I am sure its quite simple, but i am unsure so a small snippet of code on this would be highly appreciated, the txt file is called num.txt. ???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.