Working with images:

 

randimage.php

<html>

<head>

<title>Random Image</title>

</head>

<body>

<h1>Display a random image</h1>

<?php

$dogImages = array('dog150','dog225','dog250','dog350','dog625', 'dog750');

$indx = rand(0, count($dogImages)-1);

$theImage = "images/{$dogImages[$indx]}.JPG";

?>

<p>

<img src="<?php echo $theImage; ?>" />

</p>

</body>

</html>

 

randimage1.php

<html>

<head>

<title>Random Image</title>

</head>

<body>

<h1>Display a random image</h1>

<?php

$dogImages = array(

    array('picdog'  => 'dog150',

          'descpic' => 'First picture'),

    array('picdog'  => 'dog225',

          'descpic' => 'Second picture'),

    array('picdog'  => 'dog250',

          'descpic' => 'Third picture'),

    array('picdog'  => 'dog350',

          'descpic' => 'Fourth picture'),

    array('picdog'  => 'dog625',

          'descpic' => 'Fifth picture'),

    array('picdog'  => 'dog750',

          'descpic' => 'Sixth picture'));

$indx = rand(0, count($dogImages)-1);

$theImage = "images/{$dogImages[$indx]['picdog']}.JPG";

$theDesc = $dogImages[$indx]['descpic'];

?>

<p>

<img src="<?php echo $theImage; ?>" />

<?php echo $theDesc; ?>

</p>

</body>

</html>

 

randimage1a.php

<html>

<head>

<title>Random Image</title>

</head>

<body>

<h1>Display a random image</h1>

<?php

$dogImages = array(

    array('picdog'  => 'dog150',

          'descpic' => 'First picture'),

    array('picdog'  => 'dog225',

          'descpic' => 'Second picture'),

    array('picdog'  => 'dog250',

          'descpic' => 'Third picture'),

    array('picdog'  => 'dog350',

          'descpic' => 'Fourth picture'),

    array('picdog'  => 'dog625',

          'descpic' => 'Fifth picture'),

    array('picdog'  => 'dog750',

          'descpic' => 'Sixth picture'));

$indx = rand(0, count($dogImages)-1);

$theImage = "images/{$dogImages[$indx]['picdog']}.JPG";

$theDesc = $dogImages[$indx]['descpic'];

echo "<img src = '$theImage' />";

echo $theDesc;

?>

</body>

</html>

 

randimage2.php

<html>

<head>

<title>All imagaes</title>

</head>

<body>

<h1>All images</h1>

<?php

$dogImages = array('dog150','dog225','dog250','dog350','dog625', 'dog750');

foreach ($dogImages as $theImage)

  {

    $theDog = "images/$theImage.JPG";

    echo "<img src = '$theDog' />";

    echo "<img src = 'images/$theImage.JPG' />";

    echo "<br />";

  }

?>

</body>

</html>

 

randimage3a.php

<html>

<head>

<title>All images</title>

</head>

<body>

<h1>All image</h1>

<?php

$dogImages = array(

    array('picdog'  => 'dog150',

          'descpic' => 'First picture'),

    array('picdog'  => 'dog225',

          'descpic' => 'Second picture'),

    array('picdog'  => 'dog250',

          'descpic' => 'Third picture'),

    array('picdog'  => 'dog350',

          'descpic' => 'Fourth picture'),

    array('picdog'  => 'dog625',

          'descpic' => 'Fifth picture'),

    array('picdog'  => 'dog750',

          'descpic' => 'Sixth picture'));

for ($ct=0; $ct < 6; $ct++)

   {

    $theImage = "images/{$dogImages[$ct]['picdog']}.JPG";

    $theDesc = $dogImages[$ct]['descpic'];

    echo "<img src = '$theImage' />";

    echo $theDesc . "<br />";

   }

?>

</body>

</html>