Re: reduce the following code "if ($colorVar == 'Black' || $colorVar == 'Red' || $colorVar == 'White' || $colorVar == 'Blue' ){"

From: Date: Wed, 23 Mar 2005 09:46:55 +0000
Subject: Re: reduce the following code "if ($colorVar == 'Black' || $colorVar == 'Red' || $colorVar == 'White' || $colorVar == 'Blue' ){"
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-211372@lists.php.net to get a copy of this message
<?php $allColor = array('Black','Red','White','Blue'); if (in_array($colorVar, $allColor)) { $someVar = 'Something'; } ?> /frank 2005-03-23 kl. 09.54 skrev Lupita:
Hello; Can any one show me a way to reduce the following code? ###################################################### <?php if ($colorVar == 'Black' || $colorVar == 'Red' || $colorVar == 'White' || $colorVar == 'Blue' ){
    $someVar = "Something";
} ?> ######################################################## I was thinking there must be a way to place all the Colors into a $allColorVar and check to see if $colorVar = $allColorVar? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
________________________________________________ Frank Arensmeier Marketing Support NIKE HYDRAULICS AB Box 1107 631 80 Eskilstuna Sweden tel +46 16 82 34 fax +46 16 13 93 16 email: frank.arensmeier@nikehydraulics.se www.nikehydraulics.com

« previous php.general (#211372) next »