acroporas Posted September 18, 2006 Share Posted September 18, 2006 I want to display the first line, from each .txt document in the folder.But this code displays the first line of the first .txt document over and over. Why? How do I fix it?[code]<?php foreach (glob("*.txt") as $filename) { $firstline = file ( "$filename" ); echo $firstline [0] ; }?> [/code] Quote Link to comment Share on other sites More sharing options...
Mutley Posted September 18, 2006 Share Posted September 18, 2006 Just tested it and it works for me.I made 2 .txt files one named "testme.txt" (first line "hello") other was "testme2.txt" (first line "yahoo").It displayed:hello yahoo :-\ Quote Link to comment Share on other sites More sharing options...
acroporas Posted September 18, 2006 Author Share Posted September 18, 2006 Ok, you're right. I feal so stupid. All of my text files had the same first line. Doh.... Quote Link to comment 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.