Nabi Nabi - 7 months ago 29
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:

FALSE


from my array.

Answer

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.