Automattic\WooCommerce\Internal\ProductFeed\Utils
StringHelper::truncate
Truncate text to specified length
Method of the class: StringHelper{}
No Hooks.
Returns
String. Truncated text.
Usage
$result = StringHelper::truncate( $text, $max_length ): string;
- $text(string) (required)
- Text to truncate.
- $max_length(int) (required)
- Maximum length.
Changelog
| Since 10.5.0 | Introduced. |
StringHelper::truncate() StringHelper::truncate code WC 10.8.1
public static function truncate( string $text, int $max_length ): string {
if ( mb_strlen( $text ) > $max_length ) {
return mb_substr( $text, 0, $max_length );
}
return $text;
}