I had an array with duplicates. I removed the duplicates using PHP array_unique function. Then, I loop through the unique array using for loop (Sample Code below) and , I got an Undefined offset error.
$even_numbers = array(22,66,24,22,36);
$unique_even_numbers = array_unique($even_numbers);
for($i=0; $i<count($unique_even_numbers); $i++){
echo $unique_even_numbers[$i].'<br>';
}
The interesting thing is that I forgot I removed duplicates from the array somewhere (and therefore, an index). It took me something to figure out what was happening. I then used foreach. If I'm not missing something then I think it will be helpful if this is mentioned somewhere in the w3schools tutorial. It may help especially beginners.