PHP Working with files and tables
Posted: Wed Nov 26, 2008 1:39 pm
Hey,
I have a "exampledata.txt" file contain the following vlaues;
01, Richard, Hewston, 1256,
02, Matt, Mills, 9872,
03, Debbie, Close, 83642,
04, Fred, Wlesh, 1330,
......
I access the file using PHP with the following string;
$fp = fopen("example.txt", "r"); //Reads the file
and read the contains of the file using;
while (!feof($fp)){
$char = fgetc($fp);
echo $char;
}
However this returns all the value in a single line i.e. "01, Richard, Hewston, 1256, 02, Matt, Mills, 9872,......"
How can I get the code to return the values as they are in the "exampledata.txt" file, i.e. when the while loop reaches "/n" (new line) it then echo a new line on screen? (echo "/n";)
Also i want to put these values into a table format or an array? any ideas on how this can be done?
Thanks in advance for you help
I have a "exampledata.txt" file contain the following vlaues;
01, Richard, Hewston, 1256,
02, Matt, Mills, 9872,
03, Debbie, Close, 83642,
04, Fred, Wlesh, 1330,
......
I access the file using PHP with the following string;
$fp = fopen("example.txt", "r"); //Reads the file
and read the contains of the file using;
while (!feof($fp)){
$char = fgetc($fp);
echo $char;
}
However this returns all the value in a single line i.e. "01, Richard, Hewston, 1256, 02, Matt, Mills, 9872,......"
How can I get the code to return the values as they are in the "exampledata.txt" file, i.e. when the while loop reaches "/n" (new line) it then echo a new line on screen? (echo "/n";)
Also i want to put these values into a table format or an array? any ideas on how this can be done?
Thanks in advance for you help