Huh...What?
A Simple CodeIgniter Form Validation Method

In some recent CodeIgniter projects, I have had the need to check an input field against a static list of values.  So I extended the Form Validation Class and created a method called contains. This method compares the input value against the list of static values.  I have pasted the code below.

/**
 * Contains
 * 
 * Validate a submitted value against a static predefined set of values.
 * The possible values need to be a comma-separated list of values.
 * Example would be 'trim|required|contains[a,b,c]'.  The method would
 * then return true if the value is either a, b, or c, and false for
 * all others values.
 * 
 * @param string $value           The submitted value.
 * @param string $possible_values The list of valid possible values.
 * 
 * @return boolean
 */
public function contains($value, $possible_values) {
    // The validation message for this method.
    $this->set_message('contains', 'The %s field contains an invalid value.');
    // Create an array of values delimited by commas.
    $possible = explode(',', $possible_values);
    // Remove any spaces
    array_walk($possible, function(&$value, $index) { $value = trim($value); });
    // Check the array for the value.
    return in_array($value, $possible);
}

If you have any improvements you want to add just let me know.

Is My Android Phone A Bootable Device?

Just wondering……

Every time I restart my computer when I have my Android plugged in via USB, the OS fails to boot.  If I unplug my Android phone from the computer, the OS boots up.

Any body else experience these issues?

Pull files from a previous tagged git commit

My SCM of choice is Git. So for my CodeIgniter project, I need to pull file from a previous release.  (The details of which are funny.)

So I used this command to pull my file from a previous version.  (Note: Each public release is tagged with a version.)

$> git checkout 4.11.6 -- system/application/controller/a_controller_file.php

Here is a word of warning though, the file (a_controller_file.php) in the branch will loose all changes that happened after that version.

Hope this helps.