loop variable

From: Date: Wed, 07 Nov 2001 07:44:16 +0000
Subject: loop variable
Groups: php.general 
Request: Send a blank email to php-general+get-73681@lists.php.net to get a copy of this message
Hi there, I have a problem regarding the "for" loop or other types of loop. Im using the "for" loop statement to read and declare a variable for an array of elements, but my problem is when i used the declared variable outside the loop statement it does not give me the correct output. Here's my sample: <html> <head> </head> <body> <? // check for $submit if (!$submit) { // and display form ?> <form action="test2.php" method="GET"> <input type="checkbox" name="artist[]" value="Bon Jovi">Bon Jovi <input type="checkbox" name="artist[]" value="N'Sync">N'Sync <input type="checkbox" name="artist[]" value="Boyzone">Boyzone <input type="checkbox" name="artist[]" value="Britney Spears">Britney Spears <input type="checkbox" name="artist[]" value="Jethro Tull">Jethro Tull <input type="checkbox" name="artist[]" value="Crosby, Stills & Nash">Crosby, Stills & Nash <br> <input type="submit" name="submit" value="Select"> </form> <? } // or display the selected artists else { ?> <b>And here are your selections:</b> <br> <? // use a "for" loop to read and display array elements for($count = 0; $count < sizeof($artist); $count++) { echo "<i>$artist[$count]</i><br>"; $test=$artist[$count]; print("$test"); /*this line gives the proper output */ } /*print("$test"); when i used this line and comment the previous print line, it does not give me a proper out*/ } ?> </body> </html> I want to used the for loop output all thru out my program.and not just within the loop. Please help. Regards, Michael P. Carel Systems Administrator TEAM PACIFIC CORPORATION FTI Taguig Metro, Manila. PHIL. Tel. Nos. (02) 838-50-05 local 363 (02) 838-84-38 direct

« previous php.general (#73681) next »