So I have never wanted to increment an array element since I started programming but today I need to.
I got this code within a foreach statement.
Within the foreach statement I got a while loop.
The while loop uses the incrementation of the variable(change 2 array) to loop throught the code.
Now I thought about using a FOR loop.
But I need the value of the array index it's on to be incremented not the array index. How do I do it?
CODE:
Code: Select all
Foreach ($rid as $i){
while ($comp[$i] <= $now){ //Lvl up the research until stop
//Calculate an addition of time per "lvl"
$ptf = ($ptf * ($lvl[$i] /2)) - $bet[$i];
$ptf = intval($ptf);
if ($ptf <= 0){
$ptf = 1;
}
$ptf = "+" .$ptf ." min";
//
$comp[$i] = date("Y-m-d H:i:s", strtotime ($comp[$i] .$ptf));
$lvl[$i]++;
//If last time stamp passed then exit while loop & add data to database
}
}
Fatal error: Cannot increment/decrement overloaded objects nor string offsets in C:\Test\index.php on line 71
I get that there becomes an error from that but I don't know how to fix it.
Regards,
Thomas