Sample Code Listing

Below is some of the PHP code used for parsing file names, etc.

Uses Rainbow Javascript syntax highlighting code.


// Extracts data from file name convention (YYYYMMDD) into something more readable.
function getDateFromFileName($fileName) {
        $y = substr($fileName, 0, 4);
        $m = substr($fileName, 4, 2);
        $d = substr($fileName, 6, 2);          
        $originalDate = $y . "-" . $m . "-" . $d;
        $newDate = date("F j, Y", strtotime($originalDate));
        return $newDate;
}

// Returns true if string $whole ends with string $end.
function stringEndsWith($whole, $end)
{
    return (strpos($whole, $end, strlen($whole) - strlen($end)) !== false);
}