llms_trim_string( string $string, int $chars = 200, string $suffix = '...' )

Trim a string and append a suffix


Parameters Parameters

$string

(string) (Required) Input string.

$chars

(int) (Optional) Max number of characters. Default is 200.

Default value: 200

$suffix

(string) (Optional) A suffix to append. Default is '...'.

Default value: '...'


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/llms.functions.core.php

function llms_trim_string( $string, $chars = 200, $suffix = '...' ) {
	if ( strlen( $string ) > $chars ) {
		if ( function_exists( 'mb_substr' ) ) {
			$string = mb_substr( $string, 0, ( $chars - mb_strlen( $suffix ) ) ) . $suffix;
		} else {
			$string = substr( $string, 0, ( $chars - strlen( $suffix ) ) ) . $suffix;
		}
	}
	return $string;
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.