1. Go to this page and download the library: Download tezmanian/utils-str library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Tezmanian\Utils\Str\Truncate;
// Word-boundary truncation (default)
Truncate::chars('The quick brown fox jumps over the lazy dog', 20);
// 'The quick brown fox…'
Truncate::chars('The quick brown fox', 15);
// 'The quick…' ← snapped back to last complete word
// Exact cut (no word-boundary snapping)
Truncate::chars('The quick brown fox', 14, wordBoundary: false);
// 'The quick bro…'
// Custom suffix
Truncate::chars('The quick brown fox jumps', 22, suffix: ' [...]');
// 'The quick brown [...]'
// No suffix
Truncate::chars('The quick brown fox', 9, suffix: '');
// 'The quick'
// Multibyte-aware — characters, not bytes
Truncate::chars('Ärger mit Umlauten', 6);
// 'Ärger…'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.