Forum Moderators: coopster
My problem is that the strings can be the same sometimes but I would like to create one file for each (Thus with a unique filename even if the string is the same)
I thought of appending the md5 of the time and date the function was run to the filename but it seems md5 creates a 13 char string which is a bit too long for a filename.
Is there anyway to tackle this problem so that I get something shorter (Ex: "This is a test" becomes "this-is-a-test-3827.php") while still having a unique name?
Best Regards
NooK
$tail = substr($md5String,0,5); // fetch first five characters out of thirteen
then attach it with file name with . operator
$finaFileName = $filename."-".$tail.".php";
SUBSTR manual [php.net]
If you are pulling it out from a DB, the rows could be similar to the following:
. . .
12 ¦ This is a string ¦ dada
. . .
17 ¦ This is a string ¦ dada2
. . .
How about taking those ids? There must be something unique about them that enables you to identify them on the file names as well.
If not just append the timestamp
$string = $string."-".time();
Habtom