PHP code example of denshoch / utils

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

    

denshoch / utils example snippets


$text = "&#x0;&#x1";
\Denshoch\Utils::removeControlChars( $text );
var_dump( $text ); #=> ''

$html = "<div><p>Hello, world!</p></div>";
$result = \Denshoch\HtmlModifier::addClass($html, 'p', 'my-class');
=> '<div><p class="my-class">Hello, world!</p></div>'


$html = "<div><p>Hello, world!</p></div>";
$tagClassPairs = [
    'p' => 'my-class',
    'div' => 'my-other-class'
];
$result = HtmlModifier::addClassMultiple($html, $tagClassPairs);
=> '<div class="my-other-class"><p class="my-class">Hello, world!</p></div>'

vendor/bin/phpunit --bootstrap vendor/autoload.php tests