title: Matching values of an array against a string PHP
body: <p>I am working on a small project and I need some help. I have a CSV file with 150,000 rows (each row has 10 cols of data). I am using the fscvread to read the file and during the loop I want to match one of the columns (call it stringx) of each row against an array of 10,000 words. If any of the 10,000 words exist in stringx, it is removed using preg_replace. </p>
  
  <p>Now all of this is fine. I have everything working fine, but the problem is, its too slow.</p>
  
  <p>I have tried 2 methods to match the array.
  1) I convert stringx to an array using explode(" ", $stringx) and then use the array_diff($array_stringx, $array_10000);
  2) use foreach on $array_10000 and preg_replace on $stringx</p>
  
  <p>Method 1 takes about 60 secs to go through 200 rows of data and method 2 can loop 500 rows in 60 secs.</p>
  
  <p>Is there a better way to do this?</p>
  
  <p>Once again, I am looking for an efficient way to (basically) array_diff an array of 10,000 words against 150,000 strings one at a time.</p>
  
  <p>Help is much appreciated.</p>