I'm trying to make an image gallery. On the index file I want to show the albums with the images, see; http://www.robcnossen.nl/
I want to randomize the images that are inside these albums but I get all sorts of errors like:
warning: rand() expects parameter 1 to be long, string given in.
My code is;
foreach ($albums as $album) {
?><div><h2><?php
echo'<a href="view_album.php?album_id=', $album['id'],'">',$album['name'], '</a>';?> </h2><?php
echo'<a href="view_album.php?album_id=', $album["id"],'"><img src="uploads/thumbs/', $album["id"], '/', $album["imagename"],'" title="" /></a>';
?></div><?php
}
The $album["imagename"]
are the images inside the albums and I want to randomize this part. I tried for example:
rand($album["imagename"], 0)
but that gives an error.
I also tried shuffle;
foreach ($albums as $album) {
shuffle($album["imagename"]);
?><div><h2><?php
echo'<a href="view_album.php?album_id=', $album['id'],'">',$album['name'], '</a>';?></h2><?php
echo'<a href="view_album.php?album_id=', $album["id"],'"><img src="uploads/thumbs/', $album["id"], '/', $album["imagename"],'" title="" /></a>';
?></div><?php
}
But also there I get only errors.
Can anybody help me with this?
var_dump($albums);
gives
array(2) {
[0]=> array(8) {
["id"]=> string(1) "8"
["timestamp"]=> string(10) "1373890251"
["name"]=> string(7) "Holland"
["description"]=> string(19) "Fantastische foto's"
["count"]=> string(1) "2"
["imagename"]=> string(38) "KONICA MINOLTA DIGITAL CAMERA_428.jpeg"
["image"]=> string(2) "63"
["ext"]=> string(0) ""
}
[1]=> array(8) {
["id"]=> string(1) "9"
["timestamp"]=> string(10) "1376914749"
["name"]=> string(6) "Belgie"
["description"]=> string(11) "Mooi Belgie"
["count"]=> string(1) "2"
["imagename"]=> string(12) "PICT0170.JPG"
["image"]=> string(2) "66"
["ext"]=> string(0) ""
}
}
as result.