Page 1 of 1

txt.file format problem in PHP Urgent!!

Posted: Tue Sep 16, 2008 11:38 pm
by gilz.hippy
Hi..need ur guys help.I have one feedback form.The feedback form then will be kept as .txt file.My client want me to save d txt file as blow:

File name format: "enquiry-yyyyMMdd-hhmmss-X.txt" where yyyyMMdd : indicate date. example 20070816, hhmmss: indicate international time the enquiry generated in hour, minute, second. example 131520 (for 1:15:20 PM) and X: indicate the sequence no.

My problem now is.. i save d file without sequence number. I dont know how to do that..

This part of my code :

$b = 1;
$myFile = "$imagePath/irda_txt/enquiry-".date("Ymd-Gis").$b.".txt";

$fh = fopen($myFile, 'x+') or die("Can't open file");
$stringData = "$title"." $name"." $email"." $work_tel"." $mobile"." $fax"." $modecomm"." $timecomm"." $company"
." $industry"." $activities"." $website"." $enquirycat"." $enquiry";
fwrite($fh, $stringData);
fclose($fh);

Re: txt.file format problem in PHP Urgent!!

Posted: Wed Sep 17, 2008 3:20 am
by adroit
Hi,

You can split the file name by using substr() function. Take date and time out of the filename using the substr () function, convert the data and time in timestamp using mktime() funtion and sort this time and save the respective filename in array, you will get the files in sequence.

Regards

Re: txt.file format problem in PHP Urgent!!

Posted: Wed Sep 17, 2008 6:10 am
by panic!
Note: if you write URGENT!!!1 OMGz in your title, people will be less inclined to help you because you're annoying as HELL.