Solved

want to loop foreach number in a list

Posted on 2010-09-02
4
172 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 43

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 109

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

809 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