Solved

Help needed in looping through variable names

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

17 Experts available now in Live!

Get 1:1 Help Now