Re: Where's the error?

From: Date: Tue, 14 May 2002 02:42:48 +0000
Subject: Re: Where's the error?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97470@lists.php.net to get a copy of this message
On Mon, 2002-05-13 at 19:32, Josh Edwards wrote: > This is meant to grab a date out of a log file from the first line of the > array but I'm getting a parse error on line 13. Any ideas? > > function getdate($hit) There is already a PHP function named 'getdate()'; you'll need another name here. > { > $single = explode (" ",$hit); > return $single[3].$single[4]; > } > > $filename = ("combined_log"); > > fopen ($filename, "r"); fopen() is meaningless here; you don't need to use it with file(). > $fcontents = file($filename); > $limit = 1; > for ($i = 0; $i <= $limit; $i++) > { > $line = $fcontents[i]; > if ($line! = " ") The above line should be: if ($line != " ") ...but you may be better off with if (!empty($line)) ...or... if (strlen($line) > 0) ...or something like that. Hope this helps, Torben > { > $currentdate = getdate($line); > echo $currentdate; > } > } -- Torben Wilson <torben@php.net> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506

« previous php.general (#97470) next »