note 102234 deleted from language.operators.comparison by danbrown

From: Date: Thu, 03 Feb 2011 19:22:29 +0000
Subject: note 102234 deleted from language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176660@lists.php.net to get a copy of this message
Note Submitter: ojrask at gmail dot leaveout dot com ---- Hopefully this isn't something I've stupidly missed seeing from the documentation, but it seems that you can do this when comparing: <?php if ( $var == ( 'value1' || 'value2' || 'value3' ) ) { // Do stuff if $var is any of the values above. } ?> This would essentially be the same as: <?php if ( $var == 'value1' || $var == 'value2' || $var == 'value3' ) { // Do stuff. } ?> Shortens code a bit and leaves repetition out. Not sure how performance is effected.

« previous php.notes (#176660) next »