Nabi Nabi - 1 year ago 90
PHP Question

Perform logic operations on boolean array values

I have an array with boolean values, e.g.

$myarray = array(true, false, false, true, false);

Now I want to perform some logic operations on my array values, so I get the output:


from my array.

Answer Source

If you want to get the product of your array, then just use array_product() to multiply each value with each other.

$result = array_product($myarray);

Note that in your array the values TRUE and FALSE just get converted to 1 / 0.