shuffle pictures
hey-- im a php newbie, and am trying to figure out how to add a
hyperlink to the images i am using in a shuffle array. in other
words, i have a page that displays random images via the shuffle
script, and i want those images to have hyperlinks. can anyone lead
me in the right direction? here's the script:
$pictures = array('http://url1.jpg', 'http://url2.jpg');
shuffle($pictures);
?>
<?php
for ( $i = 0; $i < 1; $i++ )
{
echo '<img src=';
echo $pictures[$i];
Re: shuffle pictures
badmets [at] gmail.com wrote:
> hey-- im a php newbie, and am trying to figure out how to add a
> hyperlink to the images i am using in a shuffle array. in other
> words, i have a page that displays random images via the shuffle
> script, and i want those images to have hyperlinks. can anyone lead
> me in the right direction? here's the script:
>
> $pictures = array('http://url1.jpg', 'http://url2.jpg');
>
> shuffle($pictures);
> ?>
> <?php
> for ( $i = 0; $i < 1; $i++ )
> {
> echo '<img src=';
> echo $pictures[$i];
>
echo '<img src='.$pictures[$i].'">';
This is really a question for alt.html and not alt.php.
--
//Aho
Re: shuffle pictures
Post removed (X-No-Archive: yes)
Re: shuffle pictures
On Thu, 01 Mar 2007 17:43:32 +0100, badmets [at] gmail.com <badmets [at] gmail.com=
> =
wrote:
> hey-- im a php newbie, and am trying to figure out how to add a
> hyperlink to the images i am using in a shuffle array. in other
> words, i have a page that displays random images via the shuffle
> script, and i want those images to have hyperlinks. can anyone lead
> me in the right direction? here's the script:
>
> $pictures =3D array('http://url1.jpg', 'http://url2.jpg');
>
> shuffle($pictures);
> ?>
> <?php
> for ( $i =3D 0; $i < 1; $i++ )
> {
> echo '<img src=3D';
> echo $pictures[$i];
>
$picures =3D array(
array('href' =3D> 'http://example.com/1','src' =3D> 'url1.jpg'),
array('href' =3D> 'http://example.com/2','src' =3D> 'url2.jpg'));
shuffle($pictures);
$num_pictures =3D 5;//I assume you don't want all pictures judging by yo=
ur =
code...
$selected_pictures =3D array_splice($pictures,0,$num_pictures);
foreach($selected_pictures as $picture){
vprintf('<a href=3D"%s"><img src=3D"%s"></a>',$picture);
}
-- =
Rik Wasmus