PHP code example of md-php / html-truncation

1. Go to this page and download the library: Download md-php/html-truncation 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/ */

    

md-php / html-truncation example snippets


$truncateHtml = new \MD\HTML\Action\Truncate(allowHugeDocument: false);
$truncateHtml->withTextLength(
    html: '<p>some very long html code</p>',
    maxLength: 10,
    ending: '...'5
);  # ... will return: '<p>some very ...</p>'