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 $len = strlen($haystack);
20 for ($i = $len - 1; ($i >= 0) && (!$found);$i--) {
21 $char = $haystack[$i];
30 // Wraps text at $wrap characters
31 function wordWrap($passed, $wrap) {
32 $words = explode(" ", trim($passed));
34 $line_len = strlen($words[$i])+
1;
36 while ($i < count($words)) {
37 while ($line_len < $wrap) {
38 $line = "$line$words[$i] ";
40 $line_len = $line_len +
strlen($words[$i])+
1;
42 if ($i < count($words)) // don't <BR> the last line
44 $line_len = strlen($words[$i])+
1;