Re[4]: [PHP] Need a more elegant way of bitwise ORing values
| From: | Richard Davey | Date: | Wed, 13 Jun 2007 14:05:16 +0000 |
| Subject: | Re[4]: [PHP] Need a more elegant way of bitwise ORing values | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-256855@lists.php.net to get a copy of this message | ||
Hi Tijnema,
Wednesday, June 13, 2007, 2:42:28 PM, you wrote:
> Nice one, but you could also do it like this:
> <?php
> $filter['flags'] = FALSE;
> if ($allow_fraction)
> {
> $filter['flags'] = $filter['flags'] | FILTER_FLAG_ALLOW_FRACTION;
> }
> if ($allow_thousand)
> {
> $filter['flags'] = $filter['flags'] | FILTER_FLAG_ALLOW_THOUSAND;
> }
> if ($allow_scientific)
> {
> $filter['flags'] = $filter['flags'] | FILTER_FLAG_ALLOW_SCIENTIFIC;
> }
?>>
> Little bit simpler huh?
Yup.. even nicer, I'm using that method now :)
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"