Solved

Help needed in looping through variable names

Posted on 2007-04-03
2
245 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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 …

937 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

15 Experts available now in Live!

Get 1:1 Help Now