Re: Need a more elegant way of bitwise ORing values

From: Date: Wed, 13 Jun 2007 17:44:55 +0000
Subject: Re: Need a more elegant way of bitwise ORing values
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-256902@lists.php.net to get a copy of this message
On Wed, June 13, 2007 8:13 am, Richard Davey wrote: > Hi all, > > Can anyone think of a more elegant way of achieving the following? > > <?php > $flags = array(); $flags = 0; > > if ($allow_fraction) //Should we warn you that $allow_fraction is not actually defined?... //You don't have register_globals on, do you? > { > $flags[] = FILTER_FLAG_ALLOW_FRACTION; $flags |= FILTER_FLAG_ALLOW_FRACTION; > if (count($flags) > 0) if ($flags > 0){ > { > $c = '$c = ' . implode('|', $flags) . ';'; > eval($c); > $filter['flags'] = $c; $filter = $flags; // :-) > } > ?> > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#256902) next »