php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #10653 loop limiters
Submitted: 2001-05-03 17:49 UTC Modified: 2001-05-07 08:47 UTC
From: tboothby at felfel dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.5 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 + 15 = ?
Subscribe to this entry?

 
 [2001-05-03 17:49 UTC] tboothby at felfel dot 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-07 08:47 UTC] cynic@php.net
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++ ) ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC