Jump to content

sonnyj7

New Members
  • Posts

    2
  • Joined

  • Last visited

sonnyj7's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Let's assume that there is an EMPTY "$flavors" array that has already been established...Here's the problem: Make sure that foreach loop executes correctly if the $flavors array is NOT empty. Add one element to the $flavors array with a value of 'Avocado Chocolate'. (I can't seem to figure this out -THIS IS AN EXERCISE) Here's the STARTER code to the problem: <?php $recommendations = array(); // This is the code that I added $flavors = array() $flavors = array("Avocado Chocolate"); ?><html> <body> <h1>Flavor Recommendations</h1> <?php if (!empty($flavors)) { echo '<ul> <?php foreach ($recommendations as $flavor) { ?> <li><?php echo $flavor; ?></li> <?php } ?> </ul>' ; } else { echo '<p>There are no flavor recommendations for you.</p>'; }?> </body> </html>
  2. I'm an aspiring PHP developer, hoping to gain valuable knowledge and feedback. So guys and gals, how do I ask a question? I really could use some help with a programming exercise I am working on...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.