Solved

Displaying specific range

Posted on 2011-02-16
3
282 Views
Last Modified: 2012-05-11
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
Comment
Question by:areyouamac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
Allentkw earned 400 total points
ID: 34913245
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
 
LVL 82

Assisted Solution

by:hielo
hielo earned 100 total points
ID: 34913311
for ($i = 0; $i < ($image_num-2); $i++):
0
 

Author Closing Comment

by:areyouamac
ID: 34913332
Both worked wonderfully.

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

Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question