fork download
  1. <?php
  2.  
  3. $array = ["ab", "def", "ghi"];
  4. $excludeKeywords = ["ab", "de"];
  5.  
  6. $pattern = implode("|", $excludeKeywords);
  7. $result = preg_grep("/$pattern/i", $array);
  8.  
  9. // Positive (Reindex)
  10.  
  11. // Negative (Reindex)
  12. $result = array_diff($array, $result);
Success #stdin #stdout 0.02s 24496KB
stdin
Standard input is empty
stdout
Array
(
    [0] => ab
    [1] => def
)
Array
(
    [0] => ghi
)