I've created a script to populate an array with numbers from 0-118 and used a function to shuffle it.
e.g.:
var Arr = new Array ();
for (var i = 0; i < 119; i++) {
Arr[i] = i;
}
function shuffle(o){
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
newArray = shuffle(Arr);
I have a gallery with 24 thumbs that are named 0.jpg, 1.jpg etc 118.jpg. I need to call for each of the thumbs a number from an array.
Equivalent in php would be :
<?php $arr = array_rand(range(1, 117), 24);?>
<img src="images/<?php echo $arr[0].'.jpg'; ?>" />
Can this be done in Javascript? How should i approach it? Creating an array with the thumb's name is not practical.