+function leistungsschutzrecht_cuttext($text) {
+ $text = str_replace(array("\r", "\n"), array(" ", " "), $text);
+
+ do {
+ $oldtext = $text;
+ $text = str_replace(" ", " ", $text);
+ } while ($oldtext != $text);
+
+ $words = explode(" ", $text);
+
+ $text = "";
+ $count = 0;
+ $limit = 7;
+
+ foreach ($words as $word) {
+ if ($text != "")
+ $text .= " ";
+
+ $text .= $word;
+
+ if (++$count >= $limit) {
+ if (sizeof($words) > $limit)
+ $text .= " ...";
+
+ break;
+ }
+ }
+ return $text;
+}
+