Re: cvs: pear /Log_Parser Parser.php

From: Date: Wed, 24 Sep 2003 19:37:00 +0000
Subject: Re: cvs: pear /Log_Parser Parser.php
References: 1 2  Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13066@lists.php.net to get a copy of this message
On Wed Sep 24, 2003 at 09:0745PM +0200, Mirco 'meebey' Bauer wrote: > On Wed, 2003-09-24 at 17:34, Xavier Noguer Gallego wrote: > > - for ($i = 1; $i <= count($lineDef); $i++) { > > - $this->_indexes[$lineName][$i] = > > $config_array[$lineName][$i]['name']; > > - $this->regex[$lineName] .= > > $config_array[$lineName][$i]['pattern']; > > + for ($i = 1; $i <= (count($lineDef)); $i++) { > > + @$this->_indexes[$lineName][$i] = > > @$config_array[$lineName][$i]['name']; > > + @$this->regex[$lineName] .= > > @$config_array[$lineName][$i]['pattern']; > > putting on everything a "@" fixes your problems? > if you wan't to be sure that the array index exist, _use_ isset() not @ > and putting a function call into the for condition is not good, the > function (count()) is called on every cycle, if the value doesn't > change, like in this case ($lineDef) it should call count() once and > store it into a variable and then use the variable instead the > functioncall.... Agreed. Apart from looking better in terms of CS, having count($foo) in the loop invariant will slow down the code quite a bit, because PHP is not able to remove those invariant during execution time. -- - Martin Martin Jansen http://martinjansen.com/

« previous php.pear.cvs (#13066) next »