truncate_str()

function truncate_str(string $value, int $max_length): string

Description

Truncates a string to a specified maximum length. An ellipsis (...) is appended to indicate that the string has been shortened.

Parameters

Parameter Type Description Default
$value string The input string to be truncated. N/A
$max_length int The maximum length of the truncated string, including the ellipsis. N/A

Return Value

Type Description
string The truncated string with an ellipsis if truncated.

Example Usage