When you just want to echo one of three things in throwaway code, here’s a simple trick using PHP 5.4’s dereferencing that does it in one line.
When you just want to echo one of three things in throwaway code, here’s a simple trick using PHP 5.4’s dereferencing that does it in one line.
Outputting tables on the command line is fiddlier than it sounds, requiring some string padding trickery. Here’s a quick-and-dirty function to insta-win!
Custom routers were all-the-rage a few months ago but I’m afraid I missed the boat, so here’s my so-small-it’s-not-really-a-router router.
Six solid provisioning snippets that serve me well and make developing and provisioning with Vagrant a little bit easier.
Google will tell you how to post arrays, but what if you need to determine the name of the variable that was posted?
Sometimes you need to throw a 404 if certain conditions are met and doing so in WordPress requires a little trickery to achieve the full effect.
WordPress might not use the MVC pattern but following it in your plugins is easy with just a minor change in perspective.
A quick reference for what each log level should be used for.
So you need to get a substring between two strings? A quick Google returns about 101,000 results, the first three of which are from StackOverflow and solve the problem for rather specific use-cases. I wanted to solve the problem once-and-for-all in a more general-purpose way.
Continue reading →Unidimensional arrays and objects can be converted by casting (e.g. $array = (array) $object;
/ $object = (object) $array;
) but if multidimensional only the first tier is converted. Here’s the solution!