// of the $haystack is reached.
//*************************************************************************
function readShortMailboxName($haystack, $needle) {
- $len = strlen($haystack);
- for ($i = $len - 1; ($i >= 0) && (!$found);$i--) {
- $char = $haystack[$i];
- if ($char == $needle)
- $found = 1;
- else
- $data .= $char;
+ if (strpos($haystack, $needle)) {
+ $pos = strrpos($haystack, $needle) + 1;
+ $data = substr($haystack, $pos, strlen($haystack));
+ } else {
+ $data = $haystack;
+ }
+ return $data;
+ }
+
+ // Wraps text at $wrap characters
+ function wordWrap($passed, $wrap) {
+ $words = explode(" ", trim($passed));
+ $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<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 strrev($data);
+ 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;
+ }
?>