title: PHP - Get the Group of a user
body: <p>I am a beginner with the htaccess use, i searched an answer on google but didn't find something good to me.</p>
  
  <p>I would like to do something easy to understand (so I'm sure there is a proper way to do it) but don't know how to do.</p>
  
  <p>I have those 3 files:</p>
  
  <p>.htaccess</p>
  
  <pre><code>AuthName "Restricted Area"
  AuthType Basic 
  AuthUserFile /path/.htpasswd
  AuthGroupFile /path/.htgroups
  require group intern
  require group extern
  require group test
  </code></pre>
  
  <p>.htpasswd</p>
  
  <pre><code>user1:xxx
  user2:yyy
  user3:zzz
  </code></pre>
  
  <p>.htgroups</p>
  
  <pre><code>group1:user1 user3
  group2:user2
  </code></pre>
  
  <p>And in php i would like to make a test on the group. I will have a lot of user in some groups and i will add and remove some so i don't want to do :</p>
  
  <pre><code>if($_SERVER['PHP_AUTH_USER'] == 'user1' || $_SERVER['PHP_AUTH_USER'] == 'user2')
  </code></pre>
  
  <p>but</p>
  
  <pre><code>if($group == 'group1')
  </code></pre>
  
  <p>Could you help finding an easy way to get this variable $group ?</p>
  
  <p>Thanks a lot,</p>
  
  <p>Bastien</p>