Solved

Help needed in looping through variable names

Posted on 2007-04-03
2
263 Views
Last Modified: 2012-05-05
I need some help getting a loop together.  Basically, I have variables named, chkbox1, chkbox2, chkbox3, etc.  There are 64 of them total.  I want to loop through them all and see if they are set.  

For example:

for ( $i=1;$i<64;$i++ ) {
     if ( isset($ChkBox,$i) ) {
          echo "Variable ChkBox", $i, " is set", "<br>";
     }
}

0
Comment
Question by:Quetysis
2 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 500 total points
ID: 18847431
for ($i = 1; $i <= 64; $i++) {
    $curvar = 'ChkBox' . $i;
    if (isset($$curvar)) {
        echo 'Variable ' . $curvar . ' is set<br>';
    }
}
0
 

Author Comment

by:Quetysis
ID: 18847471
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

Title # Comments Views Activity
Dynamic Dropdowns 15 33
Why is my wamp get_include_path() wrong? 2 21
PHP Echo with auto submit 8 30
PHP delete contents of file- before writing to it 6 27
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…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

820 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