note 101724 added to control-structures.if
| From: | techguy14 at gmail dot com | Date: | Thu, 06 Jan 2011 21:39:11 +0000 |
| Subject: | note 101724 added to control-structures.if | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175506@lists.php.net to get a copy of this message | ||
You can have 'nested' if statements withing a single if statement, using additional
parenthesis.
For example, instead of having:
if( $a == 1 || $a == 2 ) {
if( $b == 3 || $b == 4 ) {
if( $c == 5 || $ d == 6 ) {
//Do something here.
}
}
}
You could just simply do this:
if( ($a==1 || $a==2) && ($b==3 || $b==4) && ($c==5 || $c==6) ) {
//do that something here.
}
Hope this helps!
----
Server IP: 69.147.83.197
Probable Submitter: 99.59.69.173
----
Manual Page -- http://www.php.net/manual/en/control-structures.if.php
Edit -- https://master.php.net/note/edit/101724
Del: integrated -- https://master.php.net/note/delete/101724/integrated
Del: useless -- https://master.php.net/note/delete/101724/useless
Del: bad code -- https://master.php.net/note/delete/101724/bad+code
Del: spam -- https://master.php.net/note/delete/101724/spam
Del: non-english -- https://master.php.net/note/delete/101724/non-english
Del: in docs -- https://master.php.net/note/delete/101724/in+docs
Del: other reasons-- https://master.php.net/note/delete/101724
Reject -- https://master.php.net/note/reject/101724
Search -- https://master.php.net/manage/user-notes.php