OK I'll try to explain it as simple as I can and if you want more you'll have to learn PHP. I will only help you make this particular peace of code work.
PHP code is written inside of HTML. The only thing you'll have to do is rename the extension of your ".html" (or ".htm") file to ".php".
PHP scripts have to be enclosed in "<?php ... ?>" tags where "..." is the actual PHP code. The above code should look like this:
PHP:
<?php
//path to the image directory
$directory = "http://x10hosting.com/forums/images/";
//get all image files with a .jpg extension.
$images = glob("" . $directory . "*.jpg");
// get random image index
$rand_img = array_rand($images, 1);
// display the image
echo '<img src="'.$images[$rand_img].'" alt="" />';
?>
PHP code inside the HTML file will be executed on the server before it returns the result to the browser. This means that your browser will only see the HTML.
The lats line in the script above (before "?>" closing tag) begins with the "echo" statement. This is the PHP output function (similar to print in other languages) that will inject any text into the HTML.
Down to the script.
"$directory" variable contains the path to the directory where you have your pics. This can be any folder on your site.
$images is an array that contains filenames of all the pics in the specified folder that have ".jpg" extension. If you would like to have more then one extension (like .gif or .png) you just have to add them to the $images variable like so:
PHP:
$images = glob("" . $directory . "*.jpg") + glob("" . $directory . "*.gif");
$rand_img gets the random index form the array of pics.
Finaly we have to inject a random image into our page. Wherever you put your "echo" function in your HTML that is where the the result will be injected. To understand it better take a look at the PHP "Halo World!" example below.
File: halo_world.php
PHP:
<html>
<head>
<title>PHP Halo World</title>
</head>
<body>
<h1><?php echo "Helo World!"; ?></h1>
</body>
</html>
As you can see the "echo" function will inject the "Halo World!" text into the HTML wherever you put it. The result page (the one browser gets) would look like this:
PHP:
<html>
<head>
<title>PHP Halo World</title>
</head>
<body>
<h1>Helo World!</h1>
</body>
</html>
In my script I echo-ed the "img" tag with "src" value containing the random image. You can put the code wherever you want your image to be displayed in your HTML page.
I hope this was clear enough and that you will be able to use it. Just remember to rename your HTML file into PHP.