title: in_array vs strpos for performance in php
body: <p>I am logging in users via windows authentication and then storing that user's rights in a session variable.  I use a delimited method of rights storage in a database i.e:</p>
  
  <pre><code>$rights //retrieved from database 
  = 'read,edit,delete,admin'
  </code></pre>
  
  <p>so my question is should I;</p>
  
  <pre><code>//generate variable
  $_SESSION['userrights'] = $rights ($rights is retrieved from database)
  
  //use strpos to find if right is allowed
  if (strpos($_SESSION['userrights'],"admin") !== false) { // do the function }
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>//make array of rights
  $_SESSION['userrights'] = explode(',',$rights)
  
  //use in_array to find if right is allowed
  if (in_array("admin",$_SESSION['userrights'])) { // do the function }
  </code></pre>
  
  <p>Bit of a OCD question as I presume the difference will be pretty much negligible for what I am doing but which would be the faster (use less resources) method?</p>
  
  <p>Any answers appreciated except ones that insult my method of rights storage!</p>