RE: [PHP-DB] How do I add multiple var to a if clause ?
If you are looking for speed and efficiency in your code then Mat has touched on it. This example will execute the fastest... If( $var <= 3 ) {} If you do or statements or and statements all of the if statement needs to be evaluated. So if you have an "or" or "and" all the statements in the if clause needs to be evaluated. Just some technical crap for the insane... Ray Hunter Firmware Engineer ENTERASYS NETWORKS -Original Message- From: matt stewart [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 21, 2002 3:47 AM To: php List Subject: RE: [PHP-DB] How do I add multiple var to a if clause ? either if (($var <= 3)&&($var >= 1)){ } if you want it to just be somewhere between one and 3, or $my_array = array ("1", "2", "3"); if (in_array($variable, $my_array)) { } if you want it to be just one of those exact values. -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: 21 February 2002 10:40 To: php List Subject: [PHP-DB] How do I add multiple var to a if clause ? Hi All If($var == 1,2,3){ } This is wrong so what is the right way. I am try to find out a if var equals either 1 2 or 3 do something type thing but cant find answers anywhere Thanks in Advance Dave Carrera Php / MySql Development Web Design Site Marketing http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.323 / Virus Database: 180 - Release Date: 08/02/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.323 / Virus Database: 180 - Release Date: 08/02/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How do I add multiple var to a if clause ?
You can use: if ( ($var == 1) or ($var == 2) or ($var == 3)) { ... } - Original Message - From: "Dave Carrera" <[EMAIL PROTECTED]> To: "php List" <[EMAIL PROTECTED]> Sent: Thursday, February 21, 2002 12:40 PM Subject: [PHP-DB] How do I add multiple var to a if clause ? > Hi All > > If($var == 1,2,3){ > } > This is wrong so what is the right way. > > I am try to find out a if var equals either 1 2 or 3 do something type > thing but cant find answers anywhere > > Thanks in Advance > > Dave Carrera > Php / MySql Development > Web Design > Site Marketing > http://www.davecarrera.com > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How do I add multiple var to a if clause ?
either if (($var <= 3)&&($var >= 1)){ } if you want it to just be somewhere between one and 3, or $my_array = array ("1", "2", "3"); if (in_array($variable, $my_array)) { } if you want it to be just one of those exact values. -Original Message- From: Dave Carrera [mailto:[EMAIL PROTECTED]] Sent: 21 February 2002 10:40 To: php List Subject: [PHP-DB] How do I add multiple var to a if clause ? Hi All If($var == 1,2,3){ } This is wrong so what is the right way. I am try to find out a if var equals either 1 2 or 3 do something type thing but cant find answers anywhere Thanks in Advance Dave Carrera Php / MySql Development Web Design Site Marketing http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.323 / Virus Database: 180 - Release Date: 08/02/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.323 / Virus Database: 180 - Release Date: 08/02/02 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How do I add multiple var to a if clause ?
Hi All If($var == 1,2,3){ } This is wrong so what is the right way. I am try to find out a if var equals either 1 2 or 3 do something type thing but cant find answers anywhere Thanks in Advance Dave Carrera Php / MySql Development Web Design Site Marketing http://www.davecarrera.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php