txt.file format problem in PHP Urgent!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gilz.hippy
Forum Newbie
Posts: 2
Joined: Tue Sep 16, 2008 11:30 pm

txt.file format problem in PHP Urgent!!

Post 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);
adroit
Forum Commoner
Posts: 37
Joined: Fri Aug 08, 2008 1:25 am
Location: India
Contact:

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

Post 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
User avatar
panic!
Forum Regular
Posts: 516
Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK

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

Post 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.
Post Reply