I am going through a few tutorials for php and I had to complicate one of the examples by adding a for..loop and I can't figure out why it won't work. Can someone figure it out?
$names = array("Peter", "Quagmire", "Joe");
$namesCount = count($names);
for($i=0; $i<$namesCount; $i+=1)
{
echo $names[i] . " ";
}
?>
ERROR MESSAGE:
PHP Notice: Use of undefined constant i - assumed 'i' in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Undefined index: i in C:\Program Files\PHP\kevin1.php on line 1
2007-07-06
01:17:25
·
4 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
PHP Notice: Use of undefined constant i - assumed 'i' in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Undefined index: i in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Use of undefined constant i - assumed 'i' in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Undefined index: i in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Use of undefined constant i - assumed 'i' in C:\Program Files\PHP\kevin1.php on line 195
PHP Notice: Undefined index: i in C:\Program Files\PHP\ke
2007-07-06
01:18:15 ·
update #1
Thanks AnalProgrammer and JACOVKSS2! You were both correct. I am not used to this php language yet. I am more used to VB .NET and ASP .NET. Thanks again!
2007-07-06
01:43:00 ·
update #2