PHP code example of eissaweb / php-html-text-content
1. Go to this page and download the library: Download eissaweb/php-html-text-content 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/ */
eissaweb / php-html-text-content example snippets
PHtmlTextContent\ReplaceTextContent;
$str = '<div>Hello World!!2</div></p>New Line 2</p>';
// ReplaceTextContent::replace($str, $search, $replace, $callback = null);
$replaced = ReplaceTextContent::replace($str, '2', '');
echo $replaced;
//Hello World!!
// New Line
HtmlTextContent\ReplaceTextContent;
$str = '<div>Hello World??2</div><div class="username"><a href="github.com/eissaweb">Eissaweb??</a></div>';
// ReplaceTextContent::replace($str, $search, $replace, $callback = null);
$replaced = ReplaceTextContent::replace($str, ['2', '?'], ['', '!'], function ($replacedStr) {
// in this case you can style the replaced text by using inline style or adding html classes to the tag as you want.
return '<span>' . $replacedStr . '</span>';
});
echo $replaced;
// Hello World!!
// Eissaweb!!
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.