FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » displaying random images with an appropriate caption
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
displaying random images with an appropriate caption [message #175931] Wed, 09 November 2011 03:34 Go to previous message
paris2venice is currently offline  paris2venice
Messages: 9
Registered: October 2011
Karma:
Junior Member
Is there any way to write something that will choose not just a random
image but the random image and its caption as a pair?

This is my code for my random images as it exists now but,
unfortunately, it doesn't work very well if I don't have a caption
with the photo (even if just to credit the photographer):


<div style="float:right; width:363px;
margin: 1.0em 2.75em 1.0em 1.0em; padding: 0.25em;
text-align:center; background-color: #fff">
<?php
$dir="/library/images/slideshow";
$images = array("$dir/farm-640x480.gif" ,
"$dir/ranch-640x480.gif" ,
"$dir/plantation-640x480.gif");
$format=' <img src="%s"
class="rounded-corners"
style="width:360px;height:270px" />';
printf("$format", $images[array_rand($images)]);
echo "\n";
?>
</div>

Thanks for any help and/or suggestions.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: php development environment in windows problems
Next Topic: Images retrives
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Oct 20 04:04:14 GMT 2024

Total time taken to generate the page: 0.05833 seconds