Okay, I'm lost. Here's what I have:
I have a list of values in a text file. What I need to do is combine like values on an HTML page.
For example (text file data):
Line 1 = a^12^Yes^6/21/04
Line 2 = b^1^No^5/14/04
Line 3 = a^5^No^6/1/04
I want the output to be like:
A 12,5 Yes,No 6/21/04,6/1/04
B 1 No 5/14/04
Here's the code currently:
Basically, what I want to do is have an array ($names) with multiple keys if the $fields[0] is already in $names array.
So:
Array(a[0]=>12^Yes^6/21/04 a[1]=>5^No^6/1/04)
Array(b[0]=>1^No^5/14/04)
I can then manipulate the print to the HTML page to show what I need.
I am confused on how to combine the like data, if that helps in the summary of what I'm trying to do.
Is there a better way or is the multi-dimensional array creation the way to go. I'm open to anything at this point.
Thx,
DreamerZ
I have a list of values in a text file. What I need to do is combine like values on an HTML page.
For example (text file data):
Line 1 = a^12^Yes^6/21/04
Line 2 = b^1^No^5/14/04
Line 3 = a^5^No^6/1/04
I want the output to be like:
A 12,5 Yes,No 6/21/04,6/1/04
B 1 No 5/14/04
Here's the code currently:
Code:
$num=1;
$i=0;
$names=array();
$values=array();
if(!($fp_openAbsence = @fopen ("openAbsences.txt", "r"))) {
echo "No Active Absences\n
<script>document.getElementById('close_Abs').disabled=true</script>";
exit; }
while (!feof($fp_openAbsence)) {
$open_abs = fgets($fp_openAbsence);
$fields = @explode("^",$open_abs);
if ($fields[0]=="\n") { unset($fields[0]); }
else {
if ($fields[0] != "") {
if(!in_array($fields[0],$names))
{
array_push($names,$fields[0]);
$values=array($names[$i]=>$names[$i]);
array_push($values,$fields[1].$fields[2]);
echo "Name array-$i: $names[$i]<BR>";
echo "Fields array-$i:"; print_r($values); echo "<BR>";
}
else
{
array_push($values,$fields[1].$fields[2]);
echo "Values: "; print_r($values); echo "<BR>";
echo "$fields[0] already in Names array<BR>";
}
echo "Array data:"; print_r($values[0]);
So:
Array(a[0]=>12^Yes^6/21/04 a[1]=>5^No^6/1/04)
Array(b[0]=>1^No^5/14/04)
I can then manipulate the print to the HTML page to show what I need.
I am confused on how to combine the like data, if that helps in the summary of what I'm trying to do.
Is there a better way or is the multi-dimensional array creation the way to go. I'm open to anything at this point.
Thx,
DreamerZ