$iLength ) ? self::getSubstring( $sString, 0, $iLength - self::getStringLength( $sSuffix ) ) . $sSuffix // ? substr( $sString, 0, $iLength - self::getStringLength( $sSuffix ) ) . $sSuffix : $sString; } /** * Indicates whether the mb_strlen() exists or not. * @since 2.1.2 * @since 3 Moved from `AmazonAutoLinks_Utility` */ static private $_bFunctionExists_mb_strlen; /** * Returns the given string length. * @since 2.1.2 * @since 3 Moved from `AmazonAutoLinks_Utility` */ static public function getStringLength( $sString ) { self::$_bFunctionExists_mb_strlen = isset( self::$_bFunctionExists_mb_strlen ) ? self::$_bFunctionExists_mb_strlen : function_exists( 'mb_strlen' ); return self::$_bFunctionExists_mb_strlen ? mb_strlen( $sString ) : strlen( $sString ); } /** * Indicates whether the mb_substr() exists or not. * @since 2.1.2 * @since 3 Moved from `AmazonAutoLinks_Utility` */ static private $_bFunctionExists_mb_substr; /** * Returns the substring of the given subject string. * @since 2.1.2 * @since 3 Moved from `AmazonAutoLinks_Utility` */ static public function getSubstring( $sString, $iStart, $iLength=null, $sEncoding=null ) { self::$_bFunctionExists_mb_substr = isset( self::$_bFunctionExists_mb_substr ) ? self::$_bFunctionExists_mb_substr : function_exists( 'mb_substr' ) && function_exists( 'mb_internal_encoding' ); if ( ! self::$_bFunctionExists_mb_substr ) { return substr( $sString, $iStart, $iLength ); } $sEncoding = isset( $sEncoding ) ? $sEncoding : mb_internal_encoding(); return mb_substr( $sString, $iStart, $iLength, $sEncoding ); } }