title: How do I take an array of strings and filter them?
body: <p>I have an array of strings in jQuery. I have another array of keywords that I want to use to filter the string array. </p>
  
  <p>My two arrays:</p>
  
  <pre><code>    var arr = new Array("Sally works at Taco Bell", "Tom drives a red car", "Tom is from Ohio", "Alex is from Ohio");
  
      var keywords = new Array("Tom", "Ohio");
  </code></pre>
  
  <p>How can I filter the <code>arr</code> array using the <code>keywords</code> array in jQuery? In this situation it would filter out "Sally works at Taco Bell" and keep the rest.</p>
  
  <p>Below is the actual code I am using.  </p>
  
  <pre><code>var keywords= [];
  var interval = "";
  var pointer = '';
  var scroll = document.getElementById("tail_print");
  
  $("#filter_button").click(
  function(){
      var id = $("#filter_box").val(); 
      if(id == "--Text--" || id == ""){
          alert("Please enter text before searching.");
      }else{
          keywords.push(id);
          $("#keywords-row").append("&lt;td&gt;&lt;img src=\"images/delete.png\" class=\"delete_filter\" /&gt; " + id + "&lt;/td&gt;");
      }
  }
  );
  
  $(".delete_filter").click(
  function(){
     ($(this)).remove(); 
  }
  );
  
  function startTail(){
  clearInterval(interval);
  interval = setInterval(
  function(){
      $.getJSON("ajax.php?function=tail&amp;pointer=" + pointer + "&amp;nocache=" + new Date(),
          function(data){
              pointer = data.pointer;
              $("#tail_print").append(data.log);
              scroll.scrollTop = scroll.scrollHeight;
          });
  }, 1000);
  }
  </code></pre>
  
  <p>The whole purpose of this is to allow the user to filter log results. So the user performs an action that starts <code>startTail()</code> and <code>$.getJSON()</code> retrieves a JSON object that is built by a PHP function and prints the results. Works flawlessly. Now I want to give the user the option to filter the incoming tailing items. The user clicks a filter button and jQuery takes the filter text and adds it to the <code>keywords</code> array then the <code>data.log</code> from the JSON object is filtered using the <code>keywords</code> array and then appended to the screen.</p>
  
  <p>I also have a delete filter function that isn't working. Maybe someone can help me with that. </p>