DanDaBeginner Posted March 24, 2007 Share Posted March 24, 2007 I dont know how to do this can someone give a tutorial or a specific function in PHP on how to know whether what file is elready existing in the folder.. -------------------------------------------------- for example: folder name: 'data' contents of 'data/' : Data1.txt, Data2.txt, Data3.txt -------------------------------------------------- I want to check it, so I can create a file next to the last file, so the new file would be 'Data4.txt'; thnx in advance Link to comment https://forums.phpfreaks.com/topic/44121-help-with-php-file/ Share on other sites More sharing options...
Crusader Posted March 24, 2007 Share Posted March 24, 2007 http://ca3.php.net/file_exists I suggest using file_exists in a loop. Link to comment https://forums.phpfreaks.com/topic/44121-help-with-php-file/#findComment-214229 Share on other sites More sharing options...
DanDaBeginner Posted March 24, 2007 Author Share Posted March 24, 2007 thanx Crusader ... got it now..for those who need, check this one: this is the code: <?php $check = FALSE; $a = 1; $path ='files/DATA'; while ($check != TRUE) { if (!file_exists('files/DATA'.$a.'.txt')) { $path = 'files/DATA'.$a.'.txt'; $check = TRUE; } $a++; } echo $path; ?> anyone that has a faster code than the one I have? plz post.. thanx Link to comment https://forums.phpfreaks.com/topic/44121-help-with-php-file/#findComment-214239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.