Need Help in PHP to get the correct output?

marcey t

New member
Here is the code
$telephonelist = fopen("recordsdirectory.txt","a+");
if (filesize ("recordsdirectory.txt")<=0)
{
echo "empty";
exit (0);
}
// read .txt file to the array
$list = file("recordsdirectory.txt");
foreach($list as $newlist)
for ($i=0; $i<count($newlist); ++$i)
$alist['$lastname,$firstname'] = '$areacode,$phonenumber';


// Table
echo "<table border='1'>";
echo "<tr>";
echo "<th> Name </th>";
echo "<th> Phone number </th>";
echo "</tr>";
// the sort
ksort($alist);
Foreach($alist as $name => $alist){
echo "<tr>";
echo "<td>$name</td>";
echo "<td>$alist</td><br>";
echo"</tr>";
}
echo"</table>";


fclose($telephonelist)

I get it to print the table but the output is not the lastname, firstname or areacode or phone number that is stored in the .txt file instead it just writes $lastname,Sfirstname in one bos then prints $areacode and $phonenumber in the other box. What am I missing?
 
Back
Top