aboutsummaryrefslogtreecommitdiffstats
path: root/functions/draw_functions.php
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-10-05 00:07:19 +0000
committerjwangen <jwangen>2002-10-05 00:07:19 +0000
commit7856c7ea0ed134c4dfee5c9ae2b4e7e2f9ab8b79 (patch)
tree47c4606d9fab5aedc732de796bf517b9d381f8d7 /functions/draw_functions.php
parentce4d8be46ccefe642883253544a4ec81bdde8cc5 (diff)
downloadphpicalendar-7856c7ea0ed134c4dfee5c9ae2b4e7e2f9ab8b79.tar.gz
phpicalendar-7856c7ea0ed134c4dfee5c9ae2b4e7e2f9ab8b79.tar.bz2
phpicalendar-7856c7ea0ed134c4dfee5c9ae2b4e7e2f9ab8b79.zip
Minor changes, implemented use configable number of lines for line wrappings
Diffstat (limited to 'functions/draw_functions.php')
-rw-r--r--functions/draw_functions.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/functions/draw_functions.php b/functions/draw_functions.php
index 52f6d47..d54c250 100644
--- a/functions/draw_functions.php
+++ b/functions/draw_functions.php
@@ -34,4 +34,27 @@ function drawEventTimes ($start, $end) {
return array ("draw_start" => ($sta_h . $sta_min), "draw_end" => ($end_h . $end_min), "draw_length" => $draw_len);
}
+
+// word wrap function that returns specified number of lines
+// when lines is 0, it returns the entire string as wordwrap() does it
+function word_wrap($str, $length, $lines=0) {
+ $str = wordwrap($str, $length);
+ if ($lines > 0) {
+ $str_arr = explode("\n", $str);
+ if (count($str_arr) < $lines) $lines = count($str_arr);
+ $str = '';
+ for ($i=0; $i<($lines-1);$i++) {
+ $str .= $str_arr[$i].'<br>';
+ }
+ if (count($str_arr) > ($lines)) {
+ $tmp_str = substr($str_arr[$i], 0, ($length-2));
+ $str .= $tmp_str . '...';
+ } else {
+ $str .= $str_arr[$i];
+ }
+ } else {
+ $str = nl2br(trim($str));
+ }
+ return $str;
+}
?> \ No newline at end of file

© 2014-2024 Faster IT GmbH | imprint | privacy policy