![]() |
PHP, read values from txt file, and add
It's me again, with for some people here probably an easy thing to code.
I have this txt file, with in it "tags" with a number value that I need to add up all together. The parts in the txt file that I need look like this: Quote:
The times that <segment bytes=" is in the file could be one time or many times! Now. How could I do this the best way? Any help appreciated! |
Using PHP
I'm not too sure about the reading bytes part sorry but below is php that will read a file line by line:
<?php $handle = @fopen("/tmp/inputfile.txt", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); echo $buffer; } fclose($handle); } ?> http://uk.php.net/fgets |
Might be something like this
Hello, something I wrote very quickly. Could have bugs, havn't tested yet.
PHP Code:
|
Quote:
This looks good! I'll give it a try later today. Thank you |
| All times are GMT +2. The time now is 19:50. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.