|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-07 08:47 UTC]
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 ) ...

for( $i = 0 ; 1000 > $i && count( $search ) > $i ; $i++ ) ...
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 12:01:27 2023 UTC