Returns a portion of a string.

substr( string input , integer start [, integer length ] )

Given a string, returns a substring of that string.

  • start is the index (starting at 0) of the string to start at.
  • length is length of the substring to return.
  • If length is not passed, the remainder of the string will be returned.


 {substr('Sailthru and Zephyr are fun', 13)}   = Zephyr are fun {substr('Sailthru and Zephyr are fun', 0, 8)} = Sailthru

Other Uses

substr() is not limited to taking a single string; you can input entire paragraphs to be returned as the substring. An example of this would be using the strip_tags() function:

{substr(strip_tags(content[0].content), x, y)}

In this example, we use strip_tags() to strip the HTML tags from the content in the data feed, returning a string. Afterwards, the substr() function returns a substring of the original string starting at integer index x, and ending at integer index y (counted in number of characters).