PHP code example of itselijahwood / profanity

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

    

itselijahwood / profanity example snippets


  
  sElijahWood\Profanity\Profanity;

  $profanity = new Profanity();
  $getList = $profanity->getProfanityList();

  echo $getList;

  $string = "fuck you";
  $profanity = new Profanity();
  $result = $profanity->filterString($string);

  if ($result) {
    echo "Swear word found."; // Output
  } else {
    echo "No swear word.";
  }

  $string = "i aint testin shit";
  $profanity = new Profanity();
  $result = $profanity->censorString($string);

  echo $result; // output: "i aint testin ****"

  $string = "sexy string";
  $replaceCensorString = "quack";

  $profanity = new Profanity();
  $getList = $profanity->replaceString($string, $replaceCensorString);

  echo $getList; // Output: quack string

  $string = "i aint testing shit";
  $customSwearWordArray = ["testing"];

  $profanity = new Profanity();
  $getString = $profanity->censorString($string, $customSwearWordArray);

  echo $getString; // Ouput: i aint ******* ****