From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Displaying a seasonal feature - PHP Tutorial
From the course: PHP for Web Designers
Solution: Displaying a seasonal feature
I hope I didn't fry your brain too much with that challenge. The idea was to change the main feature image, this image of white roses, and its associated tagline up here. Beautiful arrangements for any occasion, to match the season. And the solution lies in using a foreach loop and the in array function to identify the current season. Let's see how I did it. Let's go to the code first. And that image is on line 43. The image name begins with 980_white_rose, etcetera. We need to change that so it follows a more predictable path. So, let's open the images folder. And there is the 980 white rose. There are also three images that begin feature_, followed by a season name. There's autumn, spring, and summer. So, this one needs to be winter. Let's change that name. Feature_winter.jpg. Now, there were two arrays that I created in the text file. Let's get them, they're in arrays.txt. Let's open that, copy them, and we need to paste them into index.php. And they need to go in the code block at…
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
-
-
-
-
-
-
(Locked)
Storing multiple values in a variable as an array4m 28s
-
(Locked)
Inspecting an array's elements4m 13s
-
(Locked)
Challenge: Inserting the appropriate alt text1m 27s
-
(Locked)
Solution: Inserting the appropriate alt text5m 26s
-
(Locked)
Displaying an array as a comma-separated list3m 13s
-
(Locked)
Looping through an array's values7m 17s
-
(Locked)
Labeling array elements7m 21s
-
(Locked)
Looping through an array's labels and values5m 29s
-
Finding if a value exists in an array3m 51s
-
(Locked)
Challenge: Displaying a seasonal feature3m 6s
-
(Locked)
Solution: Displaying a seasonal feature8m 30s
-
(Locked)
-
-
-
-