|
Posted by jef.d on 06/01/07 03:58
I am attempting to read through a text file & then update an HTML page
table w/ the output from the text file (ie; statusing by table).
What I want the code to do is read through the file, look for a line
that matches a couple of strings, next is loop through the file from
that match to 30 lines searching for a "score" from, then store that
score; and then look for the next algorithm (8 of them) run & score.
What I get is an array w/ only the most recent array entry.
I have tried several things; return(), array_push(), php manual, and a
more than a few days searching online for a similar example.
Any help is greatly appreciated.
Code example below;
function fraction_0($file,$log) {
while (! feof($file)) {
$line = fgets($file,512);
if (ereg($_GET[what],$line) && ereg("_A_0",$line) &&
ereg("Request ID",$line)) {
print ("$log".htmlspecialchars($line)."<BR>");
for ($i30 = 1; $i30 < 30; $i30++){
$line = fgets($file,512);
if (!ereg("returned best solution",$line)){
if (ereg("Score from run", $line)){
print ("$log".htmlspecialchars($line)."<BR>");
$alg_score = explode(" ", $line, 512);
if (ereg($alg_score[6], 1)) {
$alg_array = array("alg0_1" => $alg_score[8]);
print "score for alg 1 is $alg_array[alg0_1]<BR>";
}elseif (ereg($alg_score[6], 2)) {
$alg_array = array("alg0_2" => $alg_score[8]);
} elseif (ereg($alg_score[6], 3)) {
$alg_array = array("alg0_3" => $alg_score[8]);
} elseif (ereg($alg_score[6], 4)) {
$alg_array = array("alg0_4" => $alg_score[8]);
} elseif (ereg($alg_score[6], 5)) {
$alg_array = array("alg0_5" => $alg_score[8]);
} elseif (ereg($alg_score[6], 6)) {
$alg_array = array("alg0_6" => $alg_score[8]);
} elseif (ereg($alg_score[6], 7)) {
$alg_array = array("alg0_7" => $alg_score[8]);
} elseif (ereg($alg_score[6], 8)) {
$alg_array = array("alg0_8" => $alg_score[8]);
}
print "<table border=\"1\"><tr><th>Alg 1</th><th>Alg 2</
th><th>Alg 3</th><th>Alg 4</th><th>Alg 5</th><th>Alg 6</th><th>Alg 7</
th><th>Alg 8</th></tr>";
print "<tr><td>$alg_array[alg0_1]</td><td>
$alg_array[alg0_2]</td><td>$alg_array[alg0_3]</td><td>
$alg_array[alg0_4]</td><td>$alg_array[alg0_5]</td><td>
$alg_array[alg0_6]</td><td>$alg_array[alg0_7]</td><td>
$alg_array[alg0_8]</td></tr>";
print "</table>";
}
} else {
print ("$log".htmlspecialchars($line)."<BR>");
$i30=30;
}
}
}
}
Caveat; I am new to PHP (~2weeks) & do not have formal scripting
background; sorry if this question is rudimentary.
Regards,
Jef
Navigation:
[Reply to this message]
|