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

From: Date: Sat, 16 Jun 2007 18:47:59 +0000
Subject: Re[7]: [PHP] Need a more elegant way of bitwise ORing values
References: 1 2 3 4 5 6 7 8  Groups: php.general 
Request: Send a blank email to php-general+get-257185@lists.php.net to get a copy of this message
Hi tedd, Saturday, June 16, 2007, 1:18:58 PM, you wrote: > How about? > switch (1) > { > case $allow_fraction: > $filter['flags'] = FILTER_FLAG_ALLOW_FRACTION; > break; > case $allow_thousand: > $filter['flags'] = FILTER_FLAG_ALLOW_THOUSAND; > break; > case $allow_scientific: > $filter['flags'] = FILTER_FLAG_ALLOW_SCIENTIFIC; > break; > } > Would that not work? Sorry but no because it doesn't allow for multiple flags to be set. It's perfectly valid to have one, two or all three flags active on the filter_var call. Even if the switch statement was re-run again, it wouldn't bitwise OR the values together, it'd just replace them. 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 (#257185) next »