What is the result between these two PHP codes?

  • Thread starter Thread starter Hello
  • Start date Start date
H

Hello

Guest
$result = 0;
$someFile = fopen("someFile.txt", "r");
for ($count = 1; $count <= 5; $count = $count + 1)
{
$nextNum = fgets($someFile);
if ($nextNum > $result)
$result = $nextNum;
}
close ($someFile);
print ("<p>The result is $result</p>)";

IS THIS CODE WILL DISPLAY THE HIGHEST OF THE 5 NUMBERS IN THE FILE?


$result = 0;
$someFile = fopen("someFile.txt", "r");
for ($count = 1; $count <= 5; $count = $count + 1)
{
$nextNum = fgets($someFile);
if ($nextNum > $result)
$result = $result + $nextNum;
}
close ($someFile);
print ("<p>The result is $result</p>)";

IS THIS ONE WILL DISPLAY THE SUM OF THE FIVE NUMBERS IN THE FILE?

CAN SOMEONE PLEASE EXPLAIN IT TO ME? THANX!!
 
Back
Top