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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tboothby at felfel dot com
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 02:03:33 2022 UTC