Re: Bug #10653 Updated: loop limiters

From: Date: Mon, 07 May 2001 20:38:09 +0000
Subject: Re: Bug #10653 Updated: loop limiters
Groups: php.dev 
Request: Send a blank email to php-dev+get-54305@lists.php.net to get a copy of this message
Yes, any integer would work. The number would act as a limiter to prevent indefinate loops. Thus, if $search had 2000 values, and you put it into a for1000() loop, it'd stop at 1000. If $search had 100 values, it'd stop at 100. This is an easy thing to code in, yes, but its annoying to have to code in limits for each and every loop. --- Bug Database <php-dev@lists.php.net> > wrote: >ID: 10653 >Updated by: cynic >Reported By: tboothby@felfel.com >Old-Status: Open >Status: Bogus >Bug Type: Feature/Change Request >Operating system: >PHP Version: 4.0.5 >Assigned To: >Comments: > >hm, would you also want while23859() ? > >also, would for1000($i=0;$i<count($search);$i++) {...} >loop 1000 times even if $search contained less than 1000 values? plainly, you have this kind of >functionality in any language. in PHP, your examples would look like this: > >$i = 0 ; >while( 100 > $i ) { > $i++ ; > $rec = mysql_fetch_row( $res ) ... >} > >and >for( $i = 0 ; 1000 > $i && count( $search ) > $i ; $i++ ) ... > >Previous Comments: >--------------------------------------------------------------------------- > >[2001-05-03 17:49:53] tboothby@felfel.com >Looping structures should (IMO) all have a limiting variant. > >For example, >while100($rec=mysql_fetch_row($res)) {...} > >Would only loop 100 times > >for1000($i=0;$i<count($search);$i++) {...} > >Would loop 1000 times, etc. > >--------------------------------------------------------------------------- > > > >ATTENTION! Do NOT reply to this email! >To reply, use the web interface found at >http://bugs.php.net/?id=10653&edit=2 _____________________________________________________________ Get your own FREE email at www.FelFel.com

« previous php.dev (#54305) next »