LIGHTENING YOUR (Web hosting ecommerce) WORKLOAD WITH INCLUDES 5. Save both
LIGHTENING YOUR WORKLOAD WITH INCLUDES 5. Save both random_image.php and index.php, and load index.php into a browser. The image should now be chosen at random. Click the Reload button in your browser, and you should see a variety of images, as shown in Figure 4-8. You can check your code for index.php against index04.php in the download files. The code for random_image.php is in random_image01.php. Figure 4-8. Storing image names in an indexed array makes it easy to display a random image. This is a simple and effective way of displaying a random image, but it would be much bet- ter if you could add a caption and set the width and height attributes for different sized images dynamically. PHP Solution 4-7: Adding a caption to the random image As I explained in Chapter 3, arrays can hold any type of data, including other arrays. To store more than one piece of information about an image, each image in the original $images array needs to be represented by a separate array. Each subarray has two 107
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.