计算for循环中的迭代次数

Currently have this.

for ($i = 0; isset($house[$i]); $i++) {
     print $i++;
}

and it returns something like this. 0,1,2,3,4,5,6,7,8,9 I want it to return that same format, but replace the initial 0 with a 1 then count forward from there, how can I achieve this?

for ($i = 1; isset($house[$i-1]); $i++) {
   echo $i;
}

Like this?

Change:

for ($i = 0; isset($house[$i]); $i++) {

To:

for ($i = 1; isset($house[$i]) + 1; $i++) {

You basically want to start the counter at 1. And the "+ 1 " adds 1 to the ending limit to allow it to reach 9

You can use $i + 1 instead of $i++

$i++ is equals to $i = $i + 1, and it's not correct way in your case

What about -

for ($i = 0; isset($house[$i]); $i++) {
    if ($i = 0){
       print 1;}
    else{
       print $i++;}
}

Be careful You are increasing the count two time .. one in the for and one in the print

for ($i = 0; isset($house[$i]); $i++) { // first increment add  and the onf a iteration
   print $i++; // second increment
}

you should simply

for ($i = 0; isset($house[$i]); $i++) {
   print $i;
}

and if you need start from 1 for count the iteration set $1= 1

for ($i = 1; isset($house[$i]); $i++) {
   print $i;
}

Try this code ! Replace the i++ with i+1

   for ($i = 0; isset($house[$i]); $i++) 
        { 
             print $i + 1 ; 
        }

Write it using pre-increment

for ($i = 0; isset($house[$i]); ) {
     print ++$i;
}