Jump to content

Vague Notice


j.silver
 Share

Recommended Posts

Hi,

This block code is from W3schools tutorials:

<?php
$cars = array("Volvo", "BMW", "Toyota");
$arrlength = count($cars);
for($x = 0; $x <= $arrlength; $x++) {
echo $cars[$x];
echo "<br>";
}
?>
The original block was without the equal sign in $x <= $arrlength;
I have added the equal sign to see what would happen. I got the same result but followed with:
Notice: Undefined offset: 3 in C:\xampp\htdocs\Testing\testing.php on line 14
I would appreciate it if someone would explain why I am getting this notice and its meaning. I thought the loop will stop and give the same result without any notice when it hits no value for the equal sign.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...