I am adding to an array on the fly, using code similar to this;
$arrayF[$f+1][$y][$x+1] = $value+1;
But I receive this in the error report:
Undefined offset: 1
QUESTION: Why do I get an undefined offset when I am trying to CREATE an array value?
What can I do about it?
Further info, if relevant: It occurs in a loop as so, where I am 'sprawling' through a masterArray
if (is_array($arrayF[$f])){
foreach ($arrayF[$f] as $key2 => $arrayF2) {
$y = $key2;
foreach ($arrayF2 as $key3 =>$value) {
$x = $key3;
if (($y<=100)&& ($y>=1)&&($x<=100)&&($x>=1)){
if ($value < $arrayMaster[$y][$x]) {
$arrayMaster[$y][$x] = $value;//resets value in a master array
$arrayF[$f+1][$y][$x+1] = $value+1;//creates a new array for F to 'sprawl' with
$max = $f+1;
}
}
}
}
}
newkeyword. They never have, and never will and for this code to even get in the loop$arrayFhas to be an array, or the outerifwould evaluate tofalse, so initializing$arrayFwon't make any difference