fork(9) download
  1. <?php
  2. $array = array('word1', 'word2', 'word3', 'word#4', 'word|4');
  3. $text = 'This is some random data1
  4. This is some word1 random data2
  5. This is some word2 random data3
  6. This is some random data4
  7. This is some word#4 random data5
  8. This is some word|4 random data6
  9. This is some word3 random data7'; // Some data
  10.  
  11.  
  12. $array = array_map(function($v){
  13. return preg_quote($v, '#');
  14. }, $array); // Escape it
  15.  
  16. $regex = '#^.*('. implode('|', $array) .').*$#m'; // construct our regex
  17. $output = preg_replace($regex, '', $text); // remove lines
  18. echo $output; // output
  19. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
This is some random data1


This is some random data4