note 40418 added to function.file
| From: | php at ligthert dot net | Date: | Wed, 03 Mar 2004 13:50:54 +0000 |
| Subject: | note 40418 added to function.file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66162@lists.php.net to get a copy of this message | ||
The following code fetches a logfile and puts everything in a array. This code snipet was originally
designed to parse squidlog file format, but could easyly serve others.
--
/* No need to limit this script */
set_time_limit(0);
/* Lets open the logfile an put it an array. */
$logfile = file("/var/squid/logs/access.log");
$i = 0;
/* Line for Line, replace dubbelspaces with nothing and put the array from the explode in an
array. */
foreach ($logfile as $line)
{
$line = ereg_replace(" ","",$line);
$logarray[$i] = explode(" ",$line);
$i++;
}
--
Enjoy
----
Manual Page -- http://www.php.net/manual/en/function.file.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40418
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40418&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40418&report=yes
Search -- http://master.php.net/manage/user-notes.php