Full Featured Type Hinting Patch
March 11th, 2008Attached is my more complete type hinting patch. It allows type hinting for int, float, string, bool, num (int or float), resource, object, and scalar.
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.
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.
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);
}