Category Archives: PHP

Check if the start of the month is in X days – PHP function

I was working on a project which required a daily cron to run and perform certain operations if it was a specific number of days before the start of the following month. I used this as a class method to … Continue reading

Posted in PHP | Comments Off

PHP Fatal error: Out of memory – Prevention better than Cure

While running a PHP script you may encounter the dreaded “Fatal error: Out of memory” message. It is usually be accompanied with a few long numbers which represent the number of bytes the script tried to allocate. The obvious fix … Continue reading

Posted in MySQL, Performance, PHP | Comments Off

Format price with 2 decimal places in PHP

Example usage:

Posted in PHP | Comments Off

Become the fastest programmer in the world

This post was influenced by the film Limitless. “An action-thriller about a writer who takes an experimental drug that allows him to use 100 percent of his mind. As one man evolves into the perfect version of himself, forces more … Continue reading

Posted in Performance, PHP, Project Management | 2 Comments

How to get Parent of Parent Post in WordPress

Posted in PHP, Wordpress | Comments Off

Generate array with x years before/after the current year

Wrote this PHP date function which can easily be used to populate a drop down in a form. e.g. credit card expiry, or date of birth. Example usage: What about months? It would be more efficient to have this as … Continue reading

Posted in PHP | Comments Off

Is today a weekday? Check with PHP

Simple PHP function to determine if today is a weekday. Could be useful if you have alternative advertising/content for weekends.

Posted in PHP | Comments Off