* @package Mammut */ /* $Id$ */ (defined('MAMMUT') && (basename(__FILE__) != basename($_SERVER['PHP_SELF']))) or die('ACCESS DENIED'); /** * searches for the last occurent of a string in another string * * @param string $haystack * string in which is searched * @param string $needle * search pattern * @return int position of the last occurrence of false if never found */ function strlastpos($haystack, $needle) { $pos = -1; $found = false; while($pos !== false) { $pos = strpos($haystack, $needle, $pos + 1); if($pos !== false) $found = $pos; } return $found; } /** * Uppercases the first letter of a string */ function strupperfirst($input) { if(strlen($input) < 2) return strtoupper($input); return strtoupper($input[0]) . substr($input, 1); } /** * Lowercases the first letter of a string */ function strlowerfirst($input) { if(strlen($input) < 2) return strtolower($input); return strtolower($input[0]) . substr($input, 1); } /** * Checks if a string starts with another string * * @param string $haystack * string in which should be searched * @param mixed $needle * the string to search * @return boolean true if the haystack starts with needle, false otherwise */ function strstartswith($haystack, $needle) { if(strlen($haystack) < strlen($needle)) return false; return strpos($haystack, $needle) === 0; }