}
-
-
-
-
function unix_newlines($str) {
$str = str_replace("\r\n", "\n", $str);
return str_replace("\r", "\n", $str);
}
+
# return current year (all 4 digits)
function this_year() {
return strftime('%Y');
return substr($text, 0, $end);
}
+# Make it easy to insert an array into the template data structure so that each
+# element of the array gets its own row.
+#
+# passed this: columnate(array('a', 'b', 'c'), 'k');
+# it returns: array(array('k' => 'a'),
+# array('k' => 'b'),
+# array('k' => 'c'));
+# passed this: columnate(array(), 'k');
+# it returns: false
+function columnize($arr, $key = 'data') {
+ if(!$arr) {
+ return false;
+ }
+ $ret = array();
+ foreach($arr as $val) {
+ $ret[] = array($key => $val);
+ }
+ return $ret;
+}
+
# php4 is broken, in that you cannot set a default value for a parameter that
# is passed by reference. So, this is set up to use the following screwy
# syntax:
return new stupid_reference($foo);
}
+function &last(&$array) {
+ if(count($array)) return $array[count($array) - 1];
+}
+
?>