Added BASIC mime support.
[squirrelmail.git] / functions / strings.php
index 422c012472c967fb9b7f01169f62b0ccab1e8620..348b62d75516995bd926ddd91e125d847046b725 100644 (file)
             $i++;
             $line_len = $line_len + strlen($words[$i])+1;
          }
-         if ($i < count($words)) // don't <BR> the last line
-            $line = "$line<BR>";
          $line_len = strlen($words[$i])+1;
+         if ($line_len < $wrap) {
+            if ($i < count($words)) // don't <BR> the last line
+               $line = "$line<BR>";
+         } else {
+            $endline = $words[$i];
+            while ($line_len >= $wrap) {
+               $bigline = substr($endline, 0, $wrap);
+               $endline = substr($endline, $wrap, strlen($endline));
+               $line_len = strlen($endline);
+               $line = "$line$bigline<BR>";
+            }
+            $line = "$line$endline<BR>";
+            $i++;
+         }
       }
       return $line;
    }
+
+   /** Returns an array of email addresses **/
+   function parseAddrs($text) {
+      $text = str_replace(" ", "", $text);
+      $text = str_replace(",", ";", $text);
+      $array = explode(";", $text);
+      return $array;
+   }
+
+   /** Returns a line of comma separated email addresses from an array **/
+   function getLineOfAddrs($array) {
+      $to_line = "";
+      for ($i = 0; $i < count($array); $i++) {
+         if ($to_line)
+            $to_line = "$to_line, $array[$i]";
+         else
+            $to_line = "$array[$i]";
+      }
+      return $to_line;
+   }
 ?>