Solved

want to loop foreach number in a list

Posted on 2010-09-02
4
177 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
[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
  • 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 110

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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