Re: Need a more elegant way of bitwise ORing values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux