fread how to Count total from Counter text
Posted
by snikolov
on Stack Overflow
See other posts from Stack Overflow
or by snikolov
Published on 2010-05-20T21:56:30Z
Indexed on
2010/05/20
22:00 UTC
Read the original article
Hit count: 244
hey i have a counter text here and i need to know how to calculate the total this is my information
$filename = "data.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); $expode = explode("\n",$contents);
/** output 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 1024 */ I i need to calculate the total by exploding "\n" so i will output 12288 need to understand how to do this i have done this
foreach ($expode as $v) { $total = $total + $v;
echo $total;
} i did not get good results with this
© Stack Overflow or respective owner