How to put this infor into a multi dimensional array?
Posted: Wed Jun 25, 2003 1:52 pm
ok, here is the situation I read in a file that has multiple data per line. I would like to put it into a multi dimensional array. Here is how I do it now so you can see.
foreach($file as $line)
{
$info = explode('|', $line);
echo " <tr>\n";
echo " <td>" . $info[0] . "</td>";
echo " <td>" . $info[1] . "</td>";
echo " <td>" . $info[2] . "</td>";
echo " <td>" . $info[3] . "</td>";
echo " </tr>\n";
$totHours += $info[2];
}
the $info array keeps 4 pieces of data from each line and spits them out. I still want to output them to the screen but I want it in an array so I know which line each one is on. Hope it makes sense...
foreach($file as $line)
{
$info = explode('|', $line);
echo " <tr>\n";
echo " <td>" . $info[0] . "</td>";
echo " <td>" . $info[1] . "</td>";
echo " <td>" . $info[2] . "</td>";
echo " <td>" . $info[3] . "</td>";
echo " </tr>\n";
$totHours += $info[2];
}
the $info array keeps 4 pieces of data from each line and spits them out. I still want to output them to the screen but I want it in an array so I know which line each one is on. Hope it makes sense...