prattmic Posted August 15, 2006 Author Share Posted August 15, 2006 bump Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-74879 Share on other sites More sharing options...
prattmic Posted August 15, 2006 Author Share Posted August 15, 2006 bump Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75126 Share on other sites More sharing options...
redarrow Posted August 15, 2006 Share Posted August 15, 2006 Have you read the manual yet on files ? Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75128 Share on other sites More sharing options...
prattmic Posted August 15, 2006 Author Share Posted August 15, 2006 no, I haven't Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75209 Share on other sites More sharing options...
prattmic Posted August 15, 2006 Author Share Posted August 15, 2006 bump Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75382 Share on other sites More sharing options...
prattmic Posted August 17, 2006 Author Share Posted August 17, 2006 bump Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75990 Share on other sites More sharing options...
hitman6003 Posted August 17, 2006 Share Posted August 17, 2006 [code]<?php$file = "./logs.txt";$limit = "5";$log = file($file);$lines = count($log);if ($lines > $limit + 19){ if (!$handle = fopen($file, 'w')) { echo "Cannot open file ($file)"; exit; } for ($i = 0; $i <= 18; $i++) { fwrite($handle, $log[$i]); unset($log[$i]); } $i = 0; while (count($log) > $limit) { unset($log[$i]); $i++; } foreach ($log as $line) { fwrite($handle, $line); } fclose($handle); } ?>[/code]Don't beg for code in the future please. Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-75996 Share on other sites More sharing options...
prattmic Posted August 17, 2006 Author Share Posted August 17, 2006 It worked! Thank you so much! Link to comment https://forums.phpfreaks.com/topic/17184-auto-prune-log/page/2/#findComment-76342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.