1.20.x views_ui.module views_ui_truncate($string, $length)

Truncate strings to a set length and provide a ... if they truncated.

This is often used in the UI to ensure long strings fit.

File

modules/views_ui/views_ui.module, line 1029
Provide structure for the administrative interface to Views.

Code

function views_ui_truncate($string, $length) {
  if (backdrop_strlen($string) > $length) {
    $string = backdrop_substr($string, 0, $length);
    $string .= '...';
  }

  return $string;
}