fork download
  1. <?php
  2.  
  3. $str = 'This is my staunch corrupt thoughts on, the stupid, stoic, psycho, that is you company founder';
  4.  
  5.  
  6.  
  7. $restrict = [
  8. 'psycho',
  9. 'staunch',
  10. 'corrupt'
  11. ];
  12.  
  13. $tmp = explode(' ', strtolower(preg_replace('/[^a-z\d ]/i', '', $str)));
  14. $r = array_intersect($restrict, $tmp);
  15.  
  16. print_r($r);
  17.  
  18. if(!empty($r)){
  19. echo "Error";
  20. } else {
  21. echo $str;
  22. }
  23.  
Success #stdin #stdout 0.01s 23740KB
stdin
Standard input is empty
stdout
Array
(
    [0] => psycho
    [1] => staunch
    [2] => corrupt
)
Error