PHP code example of stevebauman / hypertext

1. Go to this page and download the library: Download stevebauman/hypertext 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/ */

    

stevebauman / hypertext example snippets


use Stevebauman\Hypertext\Transformer;

$transformer = new Transformer();

// (Optional) Filter out specific elements by their XPath.
$transformer->filter("//*[@id='some-element']");

// (Optional) Retain new line characters.
$transformer->keepNewLines();

// (Optional) Retain anchor tags and their href attribute.
$transformer->keepLinks();

$text = $transformer->toText($html);

echo (new Transformer)->toText($html);

echo (new Transformer)->keepNewLines()->toText($html);

echo (new Transformer)->keepLinks()->toText($html);

echo (new Transformer)
    ->keepLinks()
    ->keepNewLines()
    ->toText($html);