undefined offset?!? :@@! [SOLVED]
Posted: Tue Nov 29, 2011 5:09 pm
Hello beutiful minds of Indie-resource I got a problem with an array telling me it's not defined but i'm defining it ('at least that's what I think...')
the strange thing is that i'm getting 9 errors and the array has 10 values...
Undefined offset: 2 in C:\wamp\www\Conquer\newengine.php on line 758
thats the same for Undefined offset: 2-10
here's the part of the script
yet another strange thing happens is that the script only marks me the error when all the values of the array are 0 ...
But when at least there's one value that is greater than zero, there's no error and the script works fine.
anyone got an idea why there's an undefined offset in the array?? 
the strange thing is that i'm getting 9 errors and the array has 10 values...
Undefined offset: 2 in C:\wamp\www\Conquer\newengine.php on line 758
thats the same for Undefined offset: 2-10
here's the part of the script
Code: Select all
for($i=1;$i<=10;$i++)
{
$taraname='u1'.$i.'name';
$surv1[$i]=$$taraname?$unitarray1[$$taraname][1]:false;
$taraname='u2'.$i.'name';
$surv2[$i]=$$taraname?$unitarray2[$$taraname][1]:false;
//////////////////////// LOSSES
$taraname='u1'.$i.'name';
$lost1[$i]=$$taraname?$u1firstqty[$i]-$surv1[$i]:false; /// L 758
if($lost1[$i]<0)
{$lost1[$i]=0;}
$taraname='u2'.$i.'name';
$lost2[$i]=$$taraname?$u2firstqty[$i]-$surv2[$i]:false;
if($lost2[$i]<0)
{$lost2[$i]=0;}
}// for(10)
Code: Select all
print_r($lost1); Code: Select all
Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 )Code: Select all
Array ([1] => 13 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 )