How do I write this array? Then how do I get it into a table? Please help!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Telephone Directory Sorted Array</title>
</head>
<body>
<?php
// read a file line by line
$datafile = "data_file.csv";
$fp = fopen($datafile, "r") or die("Fail to open!");
while(!feof($fp)) {
$line = fgets($fp);
echo "$line <br>";
}
fclose($fp);
// Associative Array
$lastname["lastname"] = 1;
$firstname["firstname"] = 2;
$areacode["areacode"] = 3;
$phonenum["phonenum"] = 4;
// Table header
echo "<table border='1'>";
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Phone Number</th>";
echo "</tr>";
// Sort the associate array by key
ksort($lastname);
//Print out the sorted array
foreach($lastname as $key => $val) {
echo "<tr>";
echo "<td>$lastname, $firstname</td>";
echo "<td>$areacode-$phonenum</td><br>";
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>