So I'm trying to run a simple script that rotates all the images in a directory on my page. Here is the code:

Code:
<? // Global Variables $image_dir = "$_SERVER[DOCUMENT_ROOT]/rotate"; // directory on server $image_relative_path = 'rotate'; // path to images relative to script $file_types = array('jpg','jpeg','gif','png'); $image_time = '4000'; // seconds each image will display (4000 = 4 seconds) if($handle = opendir($image_dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $ext_bits = explode(".",$file); // finds file extensions foreach($ext_bits as $key => $value){ if(in_array($value,$file_types)){ $image_rotation .= '<li><img src="'.$image_relative_path.'/'.$file.'"></li>'; } } } } closedir($handle); } ?>
That script has worked for me in the past but for some reason now, it just prints all 4 images in a row vertically on the page. I'm not sure what happened.

This is the header file it is in:

Code:
<div id="header"> <div style="position:relative;"><a href="index.php"><img class="logo" src="images/apdj_logo.png" alt="apdj_logo" width="352" height="179" border="0"/></a></div> <span style="font-family: Trebuchet MS, Arial, sans-serif; font-size: 26px; z-index:5; position:relative; left:-225px; top:145px; color:white;"> 205-767-5363 </style></span> <div style="position:relative; top:-31px;"><ul id="image_rotate" style="list-style: none;"> <?= $image_rotation; ?> </ul> </style> </div> <div id="headerbottom"></div> </div>
After going through both of those I'm stumped, it should be printing out those images one after another.