Download the PHP package marcgoertz/shorten without Composer
On this page you can find all versions of the php package marcgoertz/shorten. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download marcgoertz/shorten
More information about marcgoertz/shorten
Files in marcgoertz/shorten
Download marcgoertz/shorten
More information about marcgoertz/shorten
Files in marcgoertz/shorten
Vendor marcgoertz
Package shorten
Short Description Safely truncate HTML markup while preserving tags, handling entities, and supporting Unicode/emoji with optional word-safe truncation
License MIT
Homepage https://github.com/mrcgrtz/php-shorten
Package shorten
Short Description Safely truncate HTML markup while preserving tags, handling entities, and supporting Unicode/emoji with optional word-safe truncation
License MIT
Homepage https://github.com/mrcgrtz/php-shorten
Please rate this library. Is it a good library?
Informations about the package shorten
Shorten
Safely truncate HTML markup while preserving tags, handling entities, and supporting Unicode/emoji with optional word-safe truncation.
Installation
I recommend using Composer for installing and using Shorten:
Of course you can also just require it in your scripts directly.
Usage
Output:
Functions
truncateMarkup()
Parameters
string $markup
: Text containing markupint $length
: Maximum length of truncated text (default:400
)string $appendix
: Text added after truncated text (default:'…'
)bool $appendixInside
: Add appendix to last content in tags, increases$length
by 1 (default:false
)bool $wordsafe
: Wordsafe truncation, cuts at word boundaries (default:false
)string $delimiter
: Delimiter for wordsafe truncation (default:' '
)
Examples
Features
- ✅ Preserves HTML tag structure and proper nesting
- ✅ Handles HTML entities correctly
- ✅ Supports self-closing tags (both XML and HTML5 style)
- ✅ UTF-8 and multibyte character support (including emojis)
- ✅ Wordsafe truncation to avoid cutting words in the middle
- ✅ Configurable appendix text and placement
Related
marcgoertz/shorten-twig
is a Twig extension for this package.
License
MIT © Marc Görtz
All versions of shorten with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.2
The package marcgoertz/shorten contains the following files
Loading the files please wait ....