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
Solved

want to loop foreach number in a list

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

856 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