From the course: PHP for WordPress

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Challenge: Loop through an array of information

Challenge: Loop through an array of information

From the course: PHP for WordPress

Challenge: Loop through an array of information

(upbeat music) - [Instructor] Now that you know a bit about loops, it's time for a challenge. Given the 2D array you see on the screen here, loop through it and display all of the content, each array on a single line. So you can see that we have an array of the Teenage Mutant Ninja Turtles and certain attributes about them, like their color of their bandana, their weapon, and a descriptor. Your goal is to output the array like what you see on the screen here, where each turtle's name is in bold, and then there is a comma separated list of their attributes. Don't worry about the last comma. That's perfectly okay. That said, there are a few bonuses. The first is to trim the last comma in each list, apply keys to the attributes to make each one a little clearer, and add the attributes to a bulleted list instead of a comma separated one. Now, this isn't a graded challenge, but these are a few extra things to think about and a few additional challenges on top of your main goal.

Contents