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
 [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

Pull Requests

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: Sat Dec 21 12:01:31 2024 UTC