neil01 Posted November 21, 2007 Share Posted November 21, 2007 Hi there and thanks for reading. I have the following problem/question: I have a photo web site with different galleries. I wish to be able to re-sort the appearance of the photos so everything looks different and more dynamic , say on a daily or even weekly basis. I have written a routine in VBA which basically takes the images... puts them in a temp folder, writes to an array, sorts the array using a random sqequence and then rewites the files back to the original folder. Hope you understand? So 1.jpg may now become 6.jpg etc (also 1thumbnail.jpg will also become 6thumbnail.jpg, and the same with 1.txt -> 6.txt) It is important that that what was previously 1.jpg remains linked with 1thumbnail and 1.txt! I'm sure you understand. I then upload the images/texts again to the server. I would now like to try this in php, but am relatively new to this, my only experience has been taking wordpress themes apart If someone could point me in the right direction with arrays, shuffle etc in particular applying the same shulffle to the other folders i.e. thumbnails and texts i would be grateful. Thanking you in advance and best wishes Neil Quote Link to comment Share on other sites More sharing options...
noidtluom Posted November 21, 2007 Share Posted November 21, 2007 Uh. My approach would be to put the information (eg: names such as 1, 2, 3 etc) in an array then use shuffle(). Then use a foreach to check each new array key/value and reset the names. Quote Link to comment Share on other sites More sharing options...
prime Posted November 21, 2007 Share Posted November 21, 2007 //path to folder where images are stored $path = 'images1/'; //Store each set of pictures to it's respectiv array $images1 = array('pic1.png','pic2.png','pic3.png'); //Shuffle each of the arrays shuffle ($images1); //Generate a random picture from the shuffle $img1 = $path.$images1[rand(0, count($images1) - 1)]; After you've done the above you just simply echo it such as <img src="<?php echo "$img1"; ?>" alt="Random picture"> Quote Link to comment Share on other sites More sharing options...
neil01 Posted November 22, 2007 Author Share Posted November 22, 2007 Ok, thanks for the tips. I will give it a go, i need to be able to implement the same shuffle sequence to the texts and the thumbs... but i'll have aplay and see with what i can come up with. Once again thanks. Neil Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.