Solved

Help needed in looping through variable names

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.htaccess 5 38
Google Maps API and PHP 25 30
Php recording post 4 44
how to use a switch statement with heredoc 11 23
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
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.

778 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