note 101724 modified in control-structures.if by danbrown

From: Date: Thu, 06 Jan 2011 21:46:32 +0000
Subject: note 101724 modified in control-structures.if by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175507@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: <?php if( $a == 1 || $a == 2 ) { if( $b == 3 || $b == 4 ) { if( $c == 5 || $ d == 6 ) { //Do something here. } } } ?> You could just simply do this: <?php if( ($a==1 || $a==2) && ($b==3 || $b==4) && ($c==5 || $c==6) ) { //do that something here. } ?> Hope this helps! --was-- 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! http://php.net/manual/en/control-structures.if.php

« previous php.notes (#175507) next »