From the course: PHP for WordPress (2020)
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenge: Loop through an array of information - PHP Tutorial
From the course: PHP for WordPress (2020)
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Comparison operators and the truth4m 26s
-
(Locked)
Logical operators5m 55s
-
(Locked)
Creating if/else statements6m 53s
-
(Locked)
Conditional tags in WordPress1m 19s
-
(Locked)
Loops7m 56s
-
(Locked)
The Loop in WordPress2m 54s
-
(Locked)
Challenge: Loop through an array of information1m 18s
-
(Locked)
Solution: Loop through an array of information5m 28s
-
-
-
-