Random Background Script for BG Stretcher using PHP shuffle function

07.22.2011

Needed to shuffle the background images for bgstretcher. This is my custom php script that uses the shuffle array function that generates the list of image paths to pass in to the bgstretcher images option.

 

<?php

$imageList = array();
$imageList[1]=”bg_danshui.jpg”;
$imageList[2]=”bg_korea.jpg”;
$imageList[3]=”bg_gwangali.jpg”;
$imageList[4]=”bg_jcjesena.jpg”;
$imageList[5]=”bg_tongyung.jpg”;
$imageList[6]=”bg_seward.JPG”;

shuffle($imageList);

$bgStretcherImageList;

for($i=0; $i<sizeOf($imageList);$i++)
{
$bgStretcherImageList .= “‘http://www.travisluong.com/wp-content/themes/travisluong/images/”.$imageList[$i].”‘,”;
}

?>