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? Quote 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!"); } ?> Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/209750-super-simple-fopen-question/#findComment-1095198 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.