Solved

want to loop foreach number in a list

Posted on 2010-09-02
4
165 Views
Last Modified: 2012-05-10
i have a list of numbers 'numbers'
56
46
57
89
76

foreach (numbers as $n){

echo $n;
do something
}
0
Comment
Question by:rgb192
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 33591955
Not really sure that's a question.

You use the foreach loop on an array, so as long as your numbers are in an array, then you can loop.

$numbers = array(56, 46, 57, 89, 76);



foreach ($numbers as $n)

{

echo "Your number is " . $n;

}

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33592066
foreach() is a control structure, documented on the PHP web page here.  It operates on arrays and objects, not lists.  Please show us how your list of numbers is organized.
http://us2.php.net/manual/en/control-structures.foreach.php
0
 

Author Comment

by:rgb192
ID: 33612704
56
46
57
89
76

these are the numbers
I want to copy paste the numbers into the php code
0
 

Author Closing Comment

by:rgb192
ID: 33612715
yes,  this answered my question

thank you
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now