PHP Tips & Tricks

Truncate long string along word boundaries

Use this simple PHP code snippet to truncate a long text string along word boundaries. Very useful for displaying a summary with specified number of words from a long text.