PHP code example of infoxy / utext

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

    

infoxy / utext example snippets


use \infoxy\utext\PlainFilter;

// Note: same options as for filter, 
// but language-specific and normalizer settings not needed
$opt = [
    'filter_utf8' => true,
    'decode_entities' => true,
    'lang_quotes' => true,   // replace " with language-specific quotes
    'replace_quotes => true, // replase ' and " to curly form
    'simplify_spaces' => true,
    'collapse_spaces' => true,
    'trim' => true,
    'normalize' => true,
];

// Call static escape_filter()
$prepared_string = PlainFilter::escape_filter($input_string, $opt);

$pat = HtmlBase::classPat('class1 class2 class3');
foreach ($nodes as $n) {
  if ($n->hasAttribute('class') && preg_match($pat, $n->getAttribute('class'))) {
     // class matched with any of ones in pattern
     // DoSomething($n);
  }
}