PHP code example of heimrichhannot / truncate-html
1. Go to this page and download the library: Download heimrichhannot/truncate-html 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/ */
heimrichhannot / truncate-html example snippets
use Urodoz\Truncate\TruncateService;
$truncateService = new TruncateService();
echo $truncateService->truncate($htmlString, 100); //Truncating to 100 characters
# app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Urodoz\Truncate\Bridge\Symfony\UrodozTruncateBundle(),
);
// ...
}
// ...
}
use Urodoz\Truncate\Bridge\Twig\TruncateExtension;
use Urodoz\Truncate\TruncateService;
$twig = new Twig_Environment($loader);
$twig->addFunction(new TruncateExtension(TruncateService::create()));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.