alko123 Posted September 7, 2007 Share Posted September 7, 2007 Hi. how can i extract only the first file from a directory? Link to comment https://forums.phpfreaks.com/topic/68328-how-to-show-only-the-first-file-from-directory/ Share on other sites More sharing options...
ToonMariner Posted September 7, 2007 Share Posted September 7, 2007 http://uk2.php.net/manual/en/function.readdir.php look at example 499 and 500. all you need to do is break out of the loop once you hit your file. Link to comment https://forums.phpfreaks.com/topic/68328-how-to-show-only-the-first-file-from-directory/#findComment-343594 Share on other sites More sharing options...
alko123 Posted September 7, 2007 Author Share Posted September 7, 2007 http://uk2.php.net/manual/en/function.readdir.php look at example 499 and 500. all you need to do is break out of the loop once you hit your file. but the file names will be every time different. Link to comment https://forums.phpfreaks.com/topic/68328-how-to-show-only-the-first-file-from-directory/#findComment-343598 Share on other sites More sharing options...
ToonMariner Posted September 7, 2007 Share Posted September 7, 2007 look - there is the code to go through a directory - the second example shows youhow to ignore . and .. the rest is up to you - you find the first file and do your stuff with it then exit the loop. how hard can that be? I don't know what your file names are and (I may be guessing here but) files in a file system tend to have different names and paths - the beauty if using those examples and modifying them for your needs is that you might learn something from itthat will help you in thr future. Link to comment https://forums.phpfreaks.com/topic/68328-how-to-show-only-the-first-file-from-directory/#findComment-343607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.