-$version = '1.2.1';
-
- /**
- * Count the number of occurances of $needle are in $haystack.
- * $needle can be a character or string, and need not occur in $haystack
- */
- function countCharInString($haystack, $needle) {
- if ($needle == '') return 0;
- return count(explode($needle, $haystack));
- }
-
- /**
- * Read from the back of $haystack until $needle is found, or the begining
- * of the $haystack is reached. $needle is a single character
- */
- function readShortMailboxName($haystack, $needle) {
- if ($needle == '') return $haystack;
- $parts = explode($needle, $haystack);
- $elem = array_pop($parts);
- while ($elem == '' && count($parts))
- {
- $elem = array_pop($parts);
- }
- return $elem;
- }
-
- /**
- * Read from the back of $haystack until $needle is found, or the begining
- * of the $haystack is reached. $needle is a single character
- */
- function readMailboxParent($haystack, $needle) {
- if ($needle == '') return '';
- $parts = explode($needle, $haystack);
- $elem = array_pop($parts);
- while ($elem == '' && count($parts))
- {
- $elem = array_pop($parts);
- }
- return join($needle, $parts);
- }
-
- /**
- * Searches for the next position in a string minus white space.
- */
- function next_pos_minus_white ($haystack, $pos) {
- while (substr($haystack, $pos, 1) == ' ' ||
- substr($haystack, $pos, 1) == "\t" ||
- substr($haystack, $pos, 1) == "\n" ||
- substr($haystack, $pos, 1) == "\r") {
- if ($pos >= strlen($haystack))
- return -1;
- $pos++;
- }
- return $pos;
- }