added "cc" and "body" for searching
[squirrelmail.git] / functions / strings.php
index 1270e0276fbfa7fe8e8a9da0e4db67901bf6380d..05e155fb062d04db7bb1b1b3e3f8e6ef338ce90a 100644 (file)
       $i = 0;
       $line_len = strlen($words[$i])+1;
       $line = "";
-      while ($i < count($words)) {
-         while ($line_len < $wrap) {
-            $line = "$line$words[$i] ";
-            $i++;
-            $line_len = $line_len + strlen($words[$i])+1;
-         }
-         $line_len = strlen($words[$i])+1;
-         if ($line_len < $wrap) {
-            if ($i < count($words)) // don't <BR> the last line
-               $line = "$line\n";
-         } 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>";
+      if (count($words) > 1) {   
+         while ($i < count($words)-1) {
+            while ($line_len < $wrap) {
+               $line = "$line$words[$i] ";
+               $i++;
+               $line_len = $line_len + strlen($words[$i])+1;
+            }
+            $line_len = strlen($words[$i])+1;
+            if ($line_len < $wrap) {
+               if ($i < count($words)) // don't <BR> the last line
+                  $line = "$line\n";
+            } 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++;
             }
-            $line = "$line$endline<BR>";
-            $i++;
          }
+      } else {
+         $line = $words[0];
       }
 
       $line = str_replace(">", "&gt;", $line);
 
    function get_location () {
       # This determines the location to forward to relative
-      # to your server.  If this doesn't work correctly for
+      # to your server.  If this doesnt work correctly for
       # you (although it should), you can remove all this 
       # code except the last two lines, and change the header()
       # function to look something like this, customized to