1

I have an array

$array = array("dresses","suits");

When I try to make BITOP using phpredis

$value = implode(",",$array);
$redis->bitOp('AND','color',$value);
echo $redis->bitcount('color');

I get 0. Also tried

$value = "'".implode("','",$array)."'";

with no result. But when I make

$redis->bitOp('AND','color','dresses','suits');
echo $redis->bitcount('color');

everything is fine. It gives 30 to me

How to solve this?

George
  • 87
  • 3
  • 10

1 Answers1

0

You can do it this way:

$redis->bitOp('AND', 'color', ...$array);

Three dots before $array are called "splat operator", introduced in php 5.6

...$array means that values of $array are passed to function as variables.