Site5 - Built For Designers & Developers MENU

error message :Notice: Undefined offset: 7 in C:\xampp\htdocs\demo\forloopdemo.php on line 2

[3 Grey Star Level]

this is the code :

$company= array(
“Quiches 4 You”,
“Pie and Sauce”,
“Sandwich Bar”,
“Cake on Cake”,
“Pizzaeria Superia”,
“Burger Jack”

$numRows = sizeof($company);

for ($ii = 0; $ii

Answer #1

The message says that there is no $company[7]. How should it have, since your array goes until $company[6]?

I believe that the problem must be in the use of double quotes which allow certain elements and variables to be parsed. In this case the number “4” in the first value and the “and” in the third value.

Myself, in this case, I would have enclosed all values in single quotes which display things as they are without parsing.

$foo = “bar”;
echo “$foo” will give us bar
echo ‘$foo’ will give us $foo

Answers Answered By: swayinfo [16 Grey Star Level]

Answer this Question

You must be Logged In to post an Answer.

Not a member yet? Sign Up Now »

Money Back Guarantees
Click to verify BBB accreditation and to see a BBB report.