Array AND() ? Logical ANDing of all elements

I have an array and I want to find out if there is at least one false value in it. I was thinking of creating an array_and() function, that just performs a logical AND on all the elements. It would return true if all values are true, otherwise false. Am I over-engineering?

Answers


Why dont you just use

  • in_array — Checks if a value exists in an array

Example:

// creates an array with 10 booleans having the value true.
$array = array_fill(0, 10, TRUE);

// checking if it contains a boolean false
var_dump(in_array(FALSE, $array, TRUE)); // FALSE

// adding a boolean with the value false to the array
$array[] = FALSE;

// checking if it contains a boolean false now
var_dump(in_array(FALSE, $array, TRUE)); // TRUE

Need Your Help

Storing a complete graph in a RDBMS

database graph complete

I have several types of entities, each with their own fields, which are stored in separate tables.

SQL Time Packing of Islands

sql gaps-and-islands

I have an sql table that has something similar to this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.