Hello,
I have an array that holds images path of cd covers. The array looks
like this:
$cd = array(
589=>'sylver.jp g',
782=>'bigone.jp g',
158=>'dime.jpg'
);
I'm using a string key because i need to reference the CD in web pages
like this:
Also, because i want to be able to add elements in between and the key
string must remain.
$cd = array(
364=>'Moonlight .jpg,
589=>'sylver.jp g',
782=>'bigone.jp g',
925=>'liar.jpg' ,
158=>'dime.jpg'
);
With this array, i'm creating a thumbnail of cd covers. I'm also using
PHP pagination. I pick the first 3 elements and show the first 3
cd covers and so on..
So, here's my question: How do i pick the 3 first elements and so on
of the above array using the foreach loop function. Or should i use a
foreach loop in this case.
Can i use the foreach function to loop from n element to n element?
Here's what the code to contruct the thumbnail looks like. I'm using a
for loop but even with the for loop, i don't know how to get the key
string and the value referenced.
$start=0;
$perpage = 3;
for($i = $start; $i < $perpage $i++)
{
<a href="<?php echo $SERVER['PHP_SELF']; ?>?cd=<?php echo ??get the
key string??; ?>">
<img src="images/cd/thumbs/<?php echo ???get the value???; ?>"
alt="" />
</a>
}
Any ideas?
Marco
I have an array that holds images path of cd covers. The array looks
like this:
$cd = array(
589=>'sylver.jp g',
782=>'bigone.jp g',
158=>'dime.jpg'
);
I'm using a string key because i need to reference the CD in web pages
like this:
Also, because i want to be able to add elements in between and the key
string must remain.
$cd = array(
364=>'Moonlight .jpg,
589=>'sylver.jp g',
782=>'bigone.jp g',
925=>'liar.jpg' ,
158=>'dime.jpg'
);
With this array, i'm creating a thumbnail of cd covers. I'm also using
PHP pagination. I pick the first 3 elements and show the first 3
cd covers and so on..
So, here's my question: How do i pick the 3 first elements and so on
of the above array using the foreach loop function. Or should i use a
foreach loop in this case.
Can i use the foreach function to loop from n element to n element?
Here's what the code to contruct the thumbnail looks like. I'm using a
for loop but even with the for loop, i don't know how to get the key
string and the value referenced.
$start=0;
$perpage = 3;
for($i = $start; $i < $perpage $i++)
{
<a href="<?php echo $SERVER['PHP_SELF']; ?>?cd=<?php echo ??get the
key string??; ?>">
<img src="images/cd/thumbs/<?php echo ???get the value???; ?>"
alt="" />
</a>
}
Any ideas?
Marco
Comment