protected static function _pos(
        $haystack, $needle, $offset, $charset, $func
    )
    {
        if (Horde_Util::extensionExists('mbstring')) {
            unset($php_errormsg);
            $track_errors = ini_set('track_errors', 1);
            $ret = @call_user_func('mb_' . $func, $haystack, $needle, $offset, self::_mbstringCharset($charset));
            ini_set('track_errors', $track_errors);
            if (!isset($php_errormsg)) {
                return $ret;
            }
        }

        if (Horde_Util::extensionExists('intl')) {
            unset($php_errormsg);
            $track_errors = ini_set('track_errors', 1);
            $ret = self::convertCharset(
                @call_user_func(
                    'grapheme_' . $func,
                    self::convertCharset($haystack, $charset, 'UTF-8'),
                    self::convertCharset($needle, $charset, 'UTF-8'),
                    $offset
                ),
                'UTF-8',
                $charset
            );
            ini_set('track_errors', $track_errors);
            if (!isset($php_errormsg)) {
                return $ret;
            }
        }

        return $func($haystack, $needle, $offset);
    }
protected static function _pos(
        $haystack, $needle, $offset, $charset, $func
    )
    {
        if (Horde_Util::extensionExists('mbstring')) {
            unset($php_errormsg);
            $track_errors = ini_set('track_errors', 1);
            $ret = @call_user_func('mb_' . $func, $haystack, $needle, $offset, self::_mbstringCharset($charset));
            ini_set('track_errors', $track_errors);
            if (!isset($php_errormsg)) {
                return $ret;
            }
        }

        if (Horde_Util::extensionExists('intl')) {
            unset($php_errormsg);
            $track_errors = ini_set('track_errors', 1);
            $ret = self::convertCharset(
                @call_user_func(
                    'grapheme_' . $func,
                    self::convertCharset($haystack, $charset, 'UTF-8'),
                    self::convertCharset($needle, $charset, 'UTF-8'),
                    $offset
                ),
                'UTF-8',
                $charset
            );
            ini_set('track_errors', $track_errors);
            if (!isset($php_errormsg)) {
                return $ret;
            }
        }

        return $func($haystack, $needle, $offset);
    }
protected static function _pos ( $ haystack , $ needle , $ offset , $ charset , $ func ) { if ( Horde_Util :: extensionExists ( 'mbstring' ) ) { unset ( $ php_errormsg ) ; $ track_errors = ini_set ( 'track_errors' , 1 ) ; $ ret = @ call_user_func ( 'mb_' . $ func , $ haystack , $ needle , $ offset , self :: _mbstringCharset ( $ charset ) ) ; ini_set ( 'track_errors' , $ track_errors ) ; if ( ! isset ( $ php_errormsg ) ) { return $ ret ; } } if ( Horde_Util :: extensionExists ( 'intl' ) ) { unset ( $ php_errormsg ) ; $ track_errors = ini_set ( 'track_errors' , 1 ) ; $ ret = self :: convertCharset ( @ call_user_func ( 'grapheme_' . $ func , self :: convertCharset ( $ haystack , $ charset , 'UTF-8' ) , self :: convertCharset ( $ needle , $ charset , 'UTF-8' ) , $ offset ) , 'UTF-8' , $ charset ) ; ini_set ( 'track_errors' , $ track_errors ) ; if ( ! isset ( $ php_errormsg ) ) { return $ ret ; } } return $ func ( $ haystack , $ needle , $ offset ) ; }
Perform string position searches.

@param string $haystack  The string to search through.
@param string $needle    The string to search for.
@param integer $offset   Character in $haystack to start searching at.
@param string $charset   Charset of $needle.
@param string $func      Function to use.

@return integer  The position of occurrence.
Perform string position searches .