Fixed some MAJOR bugs
[squirrelmail.git] / functions / strings.php
index c7b6544e76ac9a7e7cddeb35363efc8e157852da..175910475cbee3e90909893107d1647ffad4a683 100644 (file)
       return strrev($data);
    }
 
+   // Wraps text at $wrap_max characters
+   function wordWrap($line) {
+      $newline = $line;
+      $lastpart = $line;
+      $numlines = 0;
+      $wrap_max = 80;
+      while (strlen($lastpart) > $wrap_max) {
+         $pos = $wrap_max;
+         while ((substr($line, $pos, $pos+1) != " ") && ($pos > 0)) {
+            $pos--;
+         }
+         $before = substr($line, 0, $pos);
+         $lastpart = substr($line, $pos+1, strlen($line));
+         $newline = $before . "<BR>" . $lastpart;
+         $numlines++;
+      }
+      return $newline;
+   }
 ?>