$path = dirname(__FILE__); $listing = array_filter(scandir($path), function($var) { // remove special directories ‘.’ and ‘..’ from listing if( preg_match(‘/^[\.]{1,2}$/’, $var) ) { return FALSE; } // remove files from listing if( !is_dir($var) ) { return FALSE; } return TRUE; }); This is a little snippet of code I’ve been using a lot recently. This function [...]
Testing if a function exists in PHP is easy. Testing if a command exists on the system is also easy. I’ve never really run into the problem of having to create a compatibility suite script to make sure my PHP script will run without trouble. Simple things like checking the version of PHP installed or the [...]
Like all good developers, I go back and look at past code to see what I could have improved and how I can apply the new knowledge to a current project. Both of the projects in question had sidebars with sections that are shared throughout the site. However, not all sections are being displayed at [...]
Even though this is not at all as important as not hardcoding copyright years. It can still a time saver if you happen to hard code your age into a biography on a website.
It’s surprising to me how often I find little functions for tedious tasks, that CodeIgniter already has built in. One of these functions is the alternator() function in the String Helper.
This code snippet is a regular expression which checks or validates a credit card number.
The Expression: ^([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{2,4})$
This code snippet is a regular expression which checks or validates a phone number.
The Expression: ^[\+]?([0-9]?)[\(|\s|\-|\.]?([0-9]{3})[\)|\s|\-|\.]*([0-9]{3})[\s|\-|\.]*([0-9]{4})$
As a developer, I am always looking for ways to increase the quality of my work and the speed at which I complete a project. One of the ways I do this is by utilizing a framework. The framework I choose is CodeIgniter.
While developing websites, I’ve frequently run into clients who would like a news system integrated on their site. A news system consists of a list of articles, usually a summary at first, and when an article has been selected, the full article is displayed. So, how do you extract the summary from the content without [...]
I was recently creating an administration application for a client. The app involved working with files and directories as well as uploading and deleting files or directories. While I was developing, I ran into an issue that required a special function: recursive delete. A recursive function is a function that has the ability to call [...]