Hi,
Im making a simple News script for my website. Its all working, Posting news via form which make a new file on the server and retrieving a list of those files and extracting the data from them etc.
the problem is... and i just realised, is that I save all data as a string with a delimiter.
for example if i put this into a form (textarea):
This is an example
oh look an empty line.
It will save in the file on the server like this:
Topic Title¦This is an example
oh look an empty line.¦19th March 06¦Webmaster¦
As you can see the delimter is the ¦ so other info in there too that we can ignore, it obviously saved the Carriage Return.
Now the problem when i read this info back into the HTML for display it ignores the carriage return, is there a way I can get this back or convert it to <BR> for HTML display?
My functons, not all in same file
Data from form to be passed to News_SaveFile()
$Data = $Topic.''."¦".''.$Message.''."¦".''.Date('dS F y').''."¦".''.$User.''."¦";
Function News_SaveFile($Text){ // News_SaveFile()
Global $News_Dir;
$FileName = time();
// Save file
$File = fopen("$News_Dir/$FileName",'w');
fputs($File,$Text);
fclose($File);
}
Function News_GetFiles(){ // News_GetFiles()
Global $News_Dir;
$TempList=''; // Store array to transfer to sesion later
$dh = opendir($News_Dir);// open the directory
// loop through files and add to array
while (false !== ( $File= readdir($dh))):
if ($File<>".." && $File<>".") {
$TempList[] = $File;
}
endwhile;
$_SESSION['News_FileList'] = $TempList; // transfer list to session
}
I hope ive given enough info.