truncate

Truncates the string to a given length.

Description

static truncate(int $length, string $substring)

If $substring is provided, and truncating occurs, the string is further truncated so that the substring may be appended without exceeding the desired length.

Parameters

  • int $length
    Desired length of the truncated string.

  • string $substring
    The substring to append if it can fit.

Return Value

static
String after truncating.