title: What is the best way to index my pages into MySQL database, for a custom PHP search engine?
body: <p>I've made this before, but I've forgotten all of the steps.  I've figured how to grab the page using the file_get_contents() function and stripped out all of the unnecessary</p>
  
  <pre><code>$data = file_get_contents("index.php"); //read the file
  $data = strip_tags($data);
  $data = strtoupper($data);
  </code></pre>
  
  <p>Next, I'm using a custom explode function which removes all of the specified separates</p>
  
  <pre><code>$sep = "   ():.,!@#$%^&amp;*[]{}?&lt;&gt;;";
  $convert = superExplode($data, $sep);
  function superExplode($str, $sep) {
      $i = 0;
      $arr[$i++] = strtok($str, $sep);
      while($token = strtok($sep))
      $arr[$i++] = $token;
      return $arr;
  }
  </code></pre>
  
  <p>And finally, I count each instance of each word using array_count_values() which stores each word as a key and word count as the value</p>
  
  <pre><code>$count = array_count_values($convert);
  </code></pre>
  
  <p>Now I can simply use a foreach loop to get the key and the word count to store in the database.  However, the problem I'm having is that, I'm getting blank keys in the $count array when I do a print_r($count).  So for example:</p>
  
  <pre><code>print_r($count);
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code> Array ([] =&gt; 1
   [] =&gt; 2 
   [] =&gt; 1 
   [HOME] =&gt; 1 
   [] =&gt; 1 
   [SUBMIT] =&gt; 1 
   [NEW] =&gt; 1 
   [VIEW] =&gt; 1)
  </code></pre>
  
  <p>How can I filter out the keys that have nothing in them?  Thanks.</p>