troubleshooting Question

HTML PHP foreach loop of array not displayed to page.

Avatar of Steve7423
Steve7423Flag for Canada asked on
PHPHTML
10 Comments1 Solution443 ViewsLast Modified:
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:     "; } ?>


      <html>
      <head>
      <body>

<?php
$colors = array("red","green","blue","yellow");
foreach ($colors as $value)
   {
   echo "$value <br>";
   }
?>

      </body>
      </html>



What should be displayed is :

red
green
blue
yellow


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.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros