Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does a comma do in the first parameter of a for loop?

Tags:

php

for-loop

What does it mean when there is a comma in the first parameter of a for loop?

For example:

for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
    //
}
like image 403
Sackling Avatar asked Nov 25 '25 01:11

Sackling


1 Answers

A comma in the first section of the loop just separates variable declarations.

Essentially it is just declaring two variables $j=0 and $n2=sizeof($quotes[$i]['methods']), but in the loop constructor instead of before the loop constructor.

like image 196
Ken Herbert Avatar answered Nov 26 '25 15:11

Ken Herbert