 <p>Try this:</p> <pre><code>div class="container slideshowContainer" style="width: 100%;"&gt; &lt;!-- BEGIN REVOLUTION SLIDER --&gt; &lt;div class="fullwidthbanner-container slider-main margin-bottom-10"&gt; &lt;div class="fullwidthabnner"&gt; &lt;ul id="revolutionul" style="display:none;"&gt; &lt;!-- OUTPUT THE SLIDES --&gt; &lt;?php shuffle($slides); foreach($slides as $d){ ?&gt; &lt;li data-transition="fade" data-slotamount="8" data-masterspeed="700" data-delay="9400" data-thumb="assets/img/sliders/revolution/thumbs/thumb2.jpg"&gt; &lt;?php if($d['slideshow_image_sub_title_4'] != ""){ ?&gt; &lt;a href="&lt;?php echo $d['slideshow_image_sub_title_4']; ?&gt;"&gt; &lt;img src="uploads/images/&lt;?php echo $d['slideshow_image_file']; ?&gt;" title="&lt;?php echo $d['slideshow_image_title']; ?&gt;" style="width: 100%;" /&gt; &lt;/a&gt; &lt;?php } else { ?&gt; &lt;img src="uploads/images/&lt;?php echo $d['slideshow_image_file']; ?&gt;" title="&lt;?php echo $d['slideshow_image_title']; ?&gt;" style="width: 100%;" /&gt; &lt;?php } ?&gt; &lt;/li&gt; &lt;?php } ?&gt; &lt;/ul&gt; &lt;div class="tp-bannertimer tp-bottom"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- END REVOLUTION SLIDER --&gt; &lt;/div&gt; </code></pre> <p><a href="http://php.net/manual/de/function.shuffle.php" rel="nofollow">http://php.net/manual/de/function.shuffle.php</a></p>