TAG: snippet

The ClanCats blog, no super fancy layout just all sort of information, stories and thoughts about coding, clancats and my other projects.

Navigation

How to do something every x clicks in PHP

There are many situations where you need to do somthing sometimes but not on every single request. There are many ways to archive this, you could implement a DB or file based counter. But if it is not important that it happens exactly after x request then this simple trick or snippet might help you out when you find yourself in a situation like: How do I cache my data for x requests? Or: Hmm how…

Useful PHP helpers: array_pick

A long time ago I added this helper to CCF's CCArr class. If you are doing a lot of Database operation you will come often to the point where you have to get a value from every row. Obviously it's not hard to write a loop doing that, but this way you will repeat yourself. This mini helper makes you write a little less code. Which is good! Usage Of course the implementation into your framework…