PHP code example of repat / censor-text

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

    

repat / censor-text example snippets


// Init
$text = new \Repat\Text();

// With Setter
$text->setText('My email address is [email protected]');
$text->censorEmail();
// returns: 'My email address is ******************'

// Chain
$text->setText('My email address is [email protected]')->censorEmail();

// In Constructor
$text = new \Repat\Text('My email address is [email protected]');

// Exchange censoring character
$text->censorEmail("❚");
// returns: My email address is ❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚❚

// Laravel
$text = resolve(\Repat\Text::class);
$text->setText('My email address is [email protected]')->censorEmail();

// Helper function
censor_email('My email address is [email protected]');
censor_email('My email address is [email protected]', "❚");