I am fixing an existing PHP code
I get error
Notice: Undefined offset: 6
The PHP code will look like below. It is a big while loop. Here I just show the main section.
$data = Array
(
[0] => 1
)
$data2 = Array
(
[0] => 1
[1] => 10
[2] => 12
[3] => 15
[4] => 17
[5] => 23
)
$i = 0;
while($data[$i]){
array_push($data,$data2);
$i++;
}
Also,
Sometimes, I get error
Notice: Undefined offset: 4
for
$data2 = Array
(
[0] => 12
[1] => 34
[2] => 56
[3] => 78
[4] => 83
)
How do I fix this issue?
foreachloop instead : php.net/manual/en/control-structures.foreach.phpwhile( isset($data[$i]) ) {The condition needs to be booleanTRUEorFALSE. Though you'd be best to use aforeachloop to traverse through an array.$data2to the end of$datawhile there is a value in$datathat sounds non-sense to me...?