PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY elements: (Web site hosting)
PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY elements: the filename and a caption. In graphical terms, it looks like this (for space reasons, only the first two items are displayed as arrays): In the original array, $images[1] is the picture of the two trainee geishas. In the multidimensional array, it still represents the same photo, but the filename is now stored in the subarray as $images[1][’file’] and the description as $images[1][’caption’]. Since the images are different sizes, you may be thinking it would be a good idea to store their width and height too. It s not necessary, because PHP can generate the details dynamically with a function called, appropriately enough, getimagesize(). This PHP solution builds on the previous one, so continue working with the same files. 1. Open random_image.php and change the code like this: ‘kinkakuji’, ‘caption’ => ‘The Golden Pavilion in Kyoto’), array(’file’ => ‘maiko’, ‘caption’ => ‘Maiko—trainee geishas in Kyoto’), array(’file’ => ‘maiko_phone’, ‘caption’ => ‘Every maiko should have one—a mobile, . of course’), array(’file’ => ‘monk’, ‘caption’ => ‘Monk begging for alms in Kyoto’), array(’file’ => ‘fountains’, ‘caption’ => ‘Fountains in central Tokyo’), array(’file’ => ‘ryoanji’, ‘caption’ => ‘Autumn leaves at Ryoanji temple, Kyoto’), array(’file’ => ‘menu’, ‘caption’ => ‘Menu outside restaurant in Pontocho, Kyoto’), array(’file’ => ‘basin’, ‘caption’ => ‘Water basin at Ryoanji temple, Kyoto’) ); $i = rand(0, count($images)-1); $selectedImage = “images/{$images[$i][’file’]}.jpg”; $caption = $images[$i][’caption’]; ?> Although the code looks complicated, it s an ordinary indexed array that contains eight items, each of which is an associative array containing definitions for ‘file’
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.