Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

php foreach array loops

I want to modify this code to display a certain range of items on my array index,but i cant use the range function

<?php include("media-files.php"); ?> <ul class="audio-files"> <?php foreach( range(1,4) as $products as $product_id => $product) { echo "<li>"; echo '<i>'.$product['name'].'</i>'; echo '<a href="download-page.php?id=' . $product_id . '">'; echo '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">'; echo '<button class="fa fa-download btn btn-primary">Download</button>'; echo "</a>"; echo "</li>"; } ?> </ul>

Antonio De Rose
Antonio De Rose
20,884 Points

could you please use code formatting, it is very hard to read it you have to use 3 backticks to open the code editor, in the area you write the question backtick is the tilda key, left key for 1