2 //*************************************************************************
3 // Count the number of occurances of $needle are in $haystack.
4 //*************************************************************************
5 function countCharInString($haystack, $needle) {
6 $len = strlen($haystack);
7 for ($i = 0; $i < $len; $i++
) {
8 if ($haystack[$i] == $needle)
14 //*************************************************************************
15 // Read from the back of $haystack until $needle is found, or the begining
16 // of the $haystack is reached.
17 //*************************************************************************
18 function readShortMailboxName($haystack, $needle) {
19 if (strpos($haystack, $needle)) {
20 $pos = strrpos($haystack, $needle) +
1;
21 $data = substr($haystack, $pos, strlen($haystack));
28 // Wraps text at $wrap characters
29 function wordWrap($passed, $wrap) {
30 $words = explode(" ", trim($passed));
32 $line_len = strlen($words[$i])+
1;
34 while ($i < count($words)) {
35 while ($line_len < $wrap) {
36 $line = "$line$words[$i] ";
38 $line_len = $line_len +
strlen($words[$i])+
1;
40 $line_len = strlen($words[$i])+
1;
41 if ($line_len < $wrap) {
42 if ($i < count($words)) // don't <BR> the last line
45 $endline = $words[$i];
46 while ($line_len >= $wrap) {
47 $bigline = substr($endline, 0, $wrap);
48 $endline = substr($endline, $wrap, strlen($endline));
49 $line_len = strlen($endline);
50 $line = "$line$bigline<BR>";
52 $line = "$line$endline<BR>";
59 /** Returns an array of email addresses **/
60 function parseAddrs($text) {
61 $text = str_replace(" ", "", $text);
62 $text = str_replace(",", ";", $text);
63 $array = explode(";", $text);
67 /** Returns a line of comma separated email addresses from an array **/
68 function getLineOfAddrs($array) {
70 for ($i = 0; $i < count($array); $i++
) {
72 $to_line = "$to_line, $array[$i]";
74 $to_line = "$array[$i]";