今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Loop through an array of information
(upbeat music) - [Instructor] All right, let's go through the solution to the last challenge. You could see we have the array on screen here, so let's start. Of course, we want to use a foreach loop for this task because we have an associative array. So I'm going to say foreach tmnt as, and then we have the turtle's name and a list of attributes. So I'm going to say turtle, arrow, and then I'll say atts for the attributes. So the first thing we want to do is print the turtle's name in bold. Since we can use HTML embedded directly into our PHP, I'm going to say echo p, b for bold, then I'll say turtle. Then I'll say colon and b and then a space. The space is important. Remember that we need to explicitly state any spaces we want in our PHP code. Now we want a comma-separated list of the attributes. So we'll actually need another foreach loop here. Foreach atts as, I'll just say attr for attribute, and then we'll…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
Comparison operators and the truth4 分钟 26 秒
-
(已锁定)
Logical operators5 分钟 55 秒
-
(已锁定)
Creating if/else statements6 分钟 53 秒
-
(已锁定)
Conditional tags in WordPress1 分钟 19 秒
-
(已锁定)
Loops7 分钟 56 秒
-
(已锁定)
The Loop in WordPress2 分钟 54 秒
-
(已锁定)
Challenge: Loop through an array of information1 分钟 18 秒
-
(已锁定)
Solution: Loop through an array of information5 分钟 28 秒
-
-
-
-