Changed size display:
[squirrelmail.git] / functions / strings.php
index 6d82b88d2cbd8379afc5fbf8d6eb0c6379125d38..b293a6c934e734f37592f140c1d40b0345e59b9d 100644 (file)
       if (count($words) > 1) {
          while ($i < count($words)) {
             // Force one word to be on a line (minimum)
-            $line .= $words[$i] . ' ';
+            $line .= $words[$i];
             $line_len = strlen($beginning_spaces) + strlen($words[$i]) +
                 strlen($words[$i + 1]) + 2;
             $i ++;
             
             // Add more words (as long as they fit)
             while ($line_len < $wrap && $i < count($words)) {
-               $line .= $words[$i] . ' ';
+               $line .= ' ' . $words[$i];
                $i++;
                $line_len += strlen($words[$i]) + 1;
             }
       
       return true;
    }
+   
+   /* Returns a string showing the size of the message/attachment */
+   function show_readable_size($bytes)
+   {
+       $bytes /= 1024;
+       $type = 'k';
+       
+       if ($bytes / 1024 > 1)
+       {
+           $bytes /= 1024;
+           $type = 'm';
+       }
+       
+       if ($bytes < 10)
+       {
+           $bytes *= 10;
+           settype($bytes, "integer");
+           $bytes /= 10;
+       }
+       else
+           settype($bytes, "integer");
+       
+       return $bytes . '<small>&nbsp;' . $type . '</small>';
+   }
 
 ?>