flag 0 or 1 on a foreach loop php
I have a query always results to two rows. How can i flag the first row
equal 1 and the second is 0?
here is the code
$rows = array(
array('number' => 1),
array('number' => 2)
);
$i=1;
foreach($rows as $r) {
if($i == 1) {
$i = 1;
} else {
$i = 0;
}
//Flag first row as 1
//Flag second row as 0;
}
Is this correct?
No comments:
Post a Comment