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: