title: Check if variable contains text or numbers
body: <p>Im creating a search function. The users are only allowed to use a-z A-Z and 0-9. How do i check if $var only contains text or numbers, and not special characters ?</p>
  
  <p>I have tried something like this:</p>
  
  <pre><code>if (!preg_match('/[^a-z]/i', $search) {
  $error = "error...";
  }
  </code></pre>
  
  <p>If anyone have a smarter solution, please let me know. It could also be something checking for special characters.</p>