Full Featured Type Hinting Patch

March 11th, 2008

Attached is my more complete type hinting patch. It allows type hinting for int, float, string, bool, num (int or float), resource, object, and scalar.

Full Scalar Type Hinting Patch

CSV Escape Functions

March 6th, 2008

Use these functions in place of fputcsv() if you are using an earlier version of php, or if you want to parse a CSV row but not write it directly to a file.

CSV Escape Functions

CSS Compression Function

March 6th, 2008

Nice function, I use it in pretty much every application I develop. I can’t guarantee that it’s safe but in all the time I’ve used it I’ve never had a problem.

I went on one of those CSS compression sites, and this function that I had wrote reduced my CSS file to 2506 bytes, exactly the same size as the most advanced compression the site offered.

function compressCss(scalar $string) {
$blank = array(”\r”, “\n”, “\t”);
$string = str_replace($blank, ”, $string);
$string = str_replace(’ {’, ‘{’, $string);
$string = str_replace(’;', ‘;’, $string);
$string = str_replace(’: ‘, ‘:’, $string);
$string = str_replace(’, ‘, ‘,’, $string);
$string = str_replace(’;}’, ‘}’, $string);
$string = str_replace(’ }’, ‘}’, $string);
$string = preg_replace(
array(’#/\*.*?\*/#s’), ”, $string
);
return trim($string);
}

Useful date/time functions.

March 6th, 2008

Attached is a few functions I have written having to do with dates and times.

Date/Time Functions