oz11 Posted July 19, 2022 Share Posted July 19, 2022 (edited) <?php $file = 'information/information.txt'; $orig = file_get_contents($file); $a = htmlentities($orig); echo '<code>'; echo '<pre>'; echo $a; echo '</pre>'; echo '</code>'; ?> I managed to get this code working, however I only want it to display the first "1000 lines" from the file.. how would i go about changing the code to do this? The idea behind the method is so that it takes users HTTP "logged" data and stores the to a text file, i only need the first 1000 lines. Thanks. Edited July 19, 2022 by oz11 cleaned code Quote Link to comment https://forums.phpfreaks.com/topic/315058-displaying-the-first-1000-lines-of-a-text-file/ Share on other sites More sharing options...
oz11 Posted July 19, 2022 Author Share Posted July 19, 2022 Nevermind.. found this: $handle = popen("tail -50l 'information/information.txt' 2>&1", 'r'); echo '<pre>'; while(!feof($handle)) { $buffer = fgets($handle); echo "$buffer"; ob_flush(); flush(); } echo '</pre>'; pclose($handle); thanks and enjoi Quote Link to comment https://forums.phpfreaks.com/topic/315058-displaying-the-first-1000-lines-of-a-text-file/#findComment-1598380 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.