snippet — Return a substring of a given piece of text.

Text-related functions

Summary

snippet($text, $startPos, $endPos, $append = '…')

Return a substring of a given piece of text.

Note: this will only split strings on the space character. this will also strip html tags from the text before getting a snippet

Parameters:
  • $text (string) – Text to take snippet of

  • $startPos (int) – Starting position of snippet in string

  • $endPos (int) – Maximum length of snippet

  • $append (string) – String to append to snippet if truncated

Returns:

string Snippet of given text

Usage

Examples

See Also