First a small warning: The solution presented in this post is not very secure and is prone to errors. It’s a quick and dirty solution to a simple problem. But since we all like to get dirty sometimes I’ll present it to you anyway.
Naveed at work is making a small chat application and wanted to store some information about which users were banned from the chat. This feature needed to be done relatively fast and since the chat does not use a database (apc only) we did not want to use a database to store this information either. I figured we could implement it fast by storing it in a regular php array.
The “database” might look like this:
<?php return array(123 => true, 456 => true, 789 => true);
As you can see we have three banned users. The keys in the array represent the IDs of these users. In the chat application we fetch the database by doing: