HTML PHP foreach loop of array not displayed to page.
Posted on 2014-01-08
I've copied code from 3wSchools.com in an effort to learn html and php. if I run the script below all I get on the screen is: "; } ?>
$colors = array("red","green","blue","yellow");
foreach ($colors as $value)
echo "$value <br>";
What should be displayed is :
this is my first week with html and I'm completely bewildered as to why this isn't working. I've tried multiple different possibilities for arrays and loops and nothing works.
is there a problem with the code or my environment? what would cause this? why can I not print out elements of an array?
the object of the game is to loop through an array and display it in a table, however first I have to get an array to display, and it won't !
Help is appreciated.