View Full Version : PHP Create Directory by date

03-28-2009, 03:36 PM
Hello all:

I am trying to create directory by date. It is something like creating a flat file database. What I am trying to do is to create a new topic. In my root directory I want to create (if the date is 2009. - YYYY.MM.DD.HH.MM.SS) then I want to create a file 2009_03_27_23_45_12.txt in 2009>03>27 directory. Now I can create a file with a php - I do have some experience with PHP but what happens if I try to create another file on the same date. I dont have to create the directories (hierarchy) again - i just need to create the file only after checking if the directories exist. I am looking for the best practice for doing this. I am looking for an example code. Please help.


03-28-2009, 03:52 PM
Check the existence of file/directory using file_exists() (http://.php.net/file_exists) and do the needful.