• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Displaying specific range

Hello,

I have a set of 7 images.

Here is the code that I am using to show the images  
for ($i = 0; $i < $image_num; $i++):

Open in new window


It starts from the 1st image, and displays all of them in order.

How can I just show images 1 - 5, and leave out images 6 and 7? Images 6 and 7 are used for other pages.

Thanks!
0
areyouamac
Asked:
areyouamac
2 Solutions
 
AllentkwCommented:
Assuming that images 1 - 5 in your array of 7 images, is ALWAYS the ones you want to show then you can use the following as your guidelines:

$maxImageNum = 5;

for ($i = 0; $i < $maxImageNum; $i++):
   //This will only loop 5 images starting from the array[0] image.

Open in new window

0
 
hieloCommented:
for ($i = 0; $i < ($image_num-2); $i++):
0
 
areyouamacAuthor Commented:
Both worked wonderfully.

I would have to give Alientkw 400 as he was able to answer first.

Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now