cgm225 Posted May 10, 2007 Share Posted May 10, 2007 How do I echo a single, specific line from a text file? Let's say, for example, the second line? Thank you all in advance! Quote Link to comment https://forums.phpfreaks.com/topic/50757-how-to-echo-a-single-specific-line-from-a-text-file/ Share on other sites More sharing options...
neel_basu Posted May 10, 2007 Share Posted May 10, 2007 <?php $str = file_get_contents('file.txt'); $lines = explode("\n", $str);//Use \r\n Instead of \n if used on Windows echo $lines[1];//Secont Line ?> Quote Link to comment https://forums.phpfreaks.com/topic/50757-how-to-echo-a-single-specific-line-from-a-text-file/#findComment-249535 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.