简体   繁体   中英

php - How to increase variable by 100

I am querying a URL (via php command line) that returns 100 values at a time only. So instead of me doing the increment (by 100) manually, how would I go about increasing it automatically?

The URL for example is: example.com/getdata.php?start=0&return=100

for ( $start = 0; $start < 300001; $start++ )
{
    print ( "$start value is ".$start ) ;
    $start = $start+100;
}

you can put increment into for loop

for ( $start = 0; $start < 300001; $start=$start + 100 )
{
    print ( "$start value is ".$start ) ;

}

your current code is increasing loop counter by once as you are using $start++ in your for loop If you replace it with $start+=100, then it will increase counter by 100. such as

for ( $start = 0; $start < 300001; $start+=100 )
{
    print ( "start value is ".$start ) ;

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM