[PHP] Multiple variables
Hi, I got a table, which contains a lot of text-boxes. Each textbox has a name: Text1 Text2 Text3 etc. Is it possible to check if they are all set using a for-loop? I think of something like: for($i=1;$i10;$i++) { if(empty(Text+$i)) { do something... } } regards, Morten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple variables
On Tue, 28 May 2002, Morten Nielsen wrote: I got a table, which contains a lot of text-boxes. Each textbox has a name: Text1 Text2 Text3 etc. Is it possible to check if they are all set using a for-loop? I think of something like: for($i=1;$i10;$i++) { if(empty(Text+$i)) { do something... } } The easiest approach would be to name your boxes like this: input name=text[1] input name=text[2] and so on. Then you can just loop through the $_REQUEST['text'] array when you're processing the form. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple variables
From my understanding of what you wrote: foreach($textBoxArray as $tBox=$tVal){ if(empty($tVal)){ echo(Found empty textBox: $tBoxbr\n); } } Read in manual about isset() and empty() cheers, thalis On Tue, 28 May 2002, Morten Nielsen wrote: Hi, I got a table, which contains a lot of text-boxes. Each textbox has a name: Text1 Text2 Text3 etc. Is it possible to check if they are all set using a for-loop? I think of something like: for($i=1;$i10;$i++) { if(empty(Text+$i)) { do something... } } regards, Morten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] multiple variables
Hi; An obvious question for some, but I am stumped: I want to use multiple optins in an if statement... if(user($arbitraryVariable)==(1 or 2 or 3 or 4)) What would be the proper syntax for this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] multiple variables
Hi! if(user($arbitraryVariable)==(1 or 2 or 3 or 4)) What would be the proper syntax for this? Here: if((user($arbitraryVariable) = 1) and ($arbitraryVariable = 4) and ($arbitraryVariable == round($arbitraryVariable))) In other cases, you'd have to write if((user($arbitraryVariable)==1) or (user($arbitraryVariable)==2) or (...)) Cheers, Kiko - It's not a bug, it's a feature. christoph starkmann mailto:[EMAIL PROTECTED] http://www.fh-augsburg.de/~kiko ICQ: 100601600 - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple variables
if (in_array($arbitraryValue,array(1,2,3,4))){ } - Original Message - From: Ralph Jarvis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 15, 2002 4:50 PM Subject: [PHP] multiple variables Hi; An obvious question for some, but I am stumped: I want to use multiple optins in an if statement... if(user($arbitraryVariable)==(1 or 2 or 3 or 4)) What would be the proper syntax for this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple variables
or use something like this: $array_values = array(1,2,3,4); if (in_array(user($arbitraryVariable), $array_values)) { // do your stuff } Greets, Edward - Original Message - From: Christoph Starkmann [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 15, 2002 4:11 PM Subject: RE: [PHP] multiple variables Hi! if(user($arbitraryVariable)==(1 or 2 or 3 or 4)) What would be the proper syntax for this? Here: if((user($arbitraryVariable) = 1) and ($arbitraryVariable = 4) and ($arbitraryVariable == round($arbitraryVariable))) In other cases, you'd have to write if((user($arbitraryVariable)==1) or (user($arbitraryVariable)==2) or (...)) Cheers, Kiko - It's not a bug, it's a feature. christoph starkmann mailto:[EMAIL PROTECTED] http://www.fh-augsburg.de/~kiko ICQ: 100601600 - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple variables
On Fri, 15 Mar 2002, Ralph Jarvis wrote: An obvious question for some, but I am stumped: I want to use multiple optins in an if statement... if(user($arbitraryVariable)==(1 or 2 or 3 or 4)) What would be the proper syntax for this? Sometimes I find a switch to be the most efficient (and least typing) approach: switch(user($arbitraryVariable)) { case 1: case 2: case 3: case 4: do whatever break; default: do the other thing } miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php