Rifts Posted August 4, 2010 Share Posted August 4, 2010 Using: $file = fopen("file1.txt", "r") or exit("Unable to open file!"); I have multiple files (file1.txt, file2.txt, etc.) how can I edit this so it just takes ANY file that ends in .txt and opens it? Link to comment https://forums.phpfreaks.com/topic/209750-super-simple-fopen-question/ Share on other sites More sharing options...
dezkit Posted August 4, 2010 Share Posted August 4, 2010 <?php foreach (glob("/*.txt") as $filename) { $file = fopen($filename, "r") or exit("Unable to open file!"); } ?> Link to comment https://forums.phpfreaks.com/topic/209750-super-simple-fopen-question/#findComment-1094987 Share on other sites More sharing options...
Rifts Posted August 4, 2010 Author Share Posted August 4, 2010 that does nothing Link to comment https://forums.phpfreaks.com/topic/209750-super-simple-fopen-question/#findComment-1095198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.