Posts in:
Code Snippet
I love taking larger functions and slimming them down into a more efficient and readable format. Here is a simple example of just that. The original function: function strip_slashes( $data ) { if( is_array($data) ) { foreach($data as $key => $val ) { $data[$key] = strip_slashes($val); } } else { return stripslashes($data); } return $data; [...]
$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 [...]
As stated in the , I have been working a lot with the Google Maps API for a current client project. The most recent problem, was the application was required to display a quick overview of the current location the user was looking at. The City and the State. Again, jQuery will be used in [...]
Google Maps API is just one of the API’s I’ve been working with recently. The most recent problem I’ve run into that needed to be solved was the ability to create a custom designed zoom slider, replacing the default. The default one was not gonna work for this project and the designer created a better [...]
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})$
How you handle the saving and display of images is very important while planning your web app. Questions you would ask yourself include: How should images be stored? What will the standard naming conventions be? How will thumbnails be created? In this article, I will be focusing on how I decided the way thumbnails would [...]
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 [...]