Quick Example

Be sure to include the arrch.php file in your script or app.

include 'lib/arrch.php';

We'll use Arrch to try and find Brian using a few conditions that return true for Brian's data. You can traverse the multidimensional arrays in your query by using dot (.) notation, and use a standard collection of operators (which are listed below) to determine a match.

You may be wondering about the tilde (~) operator. That one is comparable to MySQL's LIKE statement. You can use it to check for similarity in strings, numbers, and even determine if an associative array key exists.

Limitations

Use this library in large-scale production environments at your own risk. Processing large arrays in runtime memory is a slow process, and you could experience major hangups when dealing with huge amounts of data. In those instances, why not stick with a legitimate database interface and solution like the PHP core extensions for MySQL, PostgreSQL, MongoDB, etc. and associated, more mature abstracted database libraries.

Arrch may find it's a niche in smaller-scale, flat-file storage environments. Of course, this library could work with any database solution, but you'd have to load the entirety of the collection into memory at once in order to query against it. That might not be a good time.

At the very least, it's fun to play around with a simple PHP solution that doesn't require MySQL. Just be honest with yourself about your project's requirements before you begin, and don't code yourself into a hole!