Re[6]: [PHP] Need a more elegant way of bitwise ORing values

From: Date: Wed, 13 Jun 2007 14:19:37 +0000
Subject: Re[6]: [PHP] Need a more elegant way of bitwise ORing values
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-256865@lists.php.net to get a copy of this message
Hi Robert, Wednesday, June 13, 2007, 3:15:39 PM, you wrote: > It's terribly verbose and inefficient... > <?php > $filter['flags'] = 0; > if( $allow_fraction ) > { > $filter['flags'] |= FILTER_FLAG_ALLOW_FRACTION; > } > if( $allow_thousand ) > { > $filter['flags'] |= FILTER_FLAG_ALLOW_THOUSAND; > } > if( $allow_scientific ) > { > $filter['flags'] |= FILTER_FLAG_ALLOW_SCIENTIFIC; > } ?>> I don't think it's *terribly* verbose, as it has good sentence structure to it, but your version is certainly more efficient, hence I've swapped to that. Any other takers? ;) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk "Never trust a computer you can't throw out of a window"

« previous php.general (#256865) next »