title: Show checkbox as checked when value matches php
body: <p>Retriving the roles of user using user id</p>
  
  <pre><code>$userId = $userDetails['user_id'];
  $stmt = $db-&gt;query ( "SELECT user_role_id FROM user_role_xref where user_id=" . $userId);
  $userRoles = $stmt-&gt;fetchAll ();
  print_r($userRoles);
  </code></pre>
  
  <p>When i print this </p>
  
  <pre><code>Array ( 
      [0] =&gt; Array ( 
          [user_role_id] =&gt; 3 
      ) 
      [1] =&gt; Array ( 
          [user_role_id] =&gt; 4 
      ) 
      [2] =&gt; Array ( 
          [user_role_id] =&gt; 5 ) 
      ) 
  </code></pre>
  
  <p>how to show check box as checked when value matches else checkbox is unchecked</p>
  
  <pre><code>&lt;input type="checkbox" id="roles_1" value="3" name="roles[]" /&gt;
  &lt;label for="roles_1"&gt;Role1&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" id="roles_2" value="4" name="roles[]" /&gt;
  &lt;label for="roles_2"&gt;Role2&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" id="roles_3" value="5" name="roles[]" /&gt; 
  &lt;label for="roles_3"&gt;Role3&lt;/label&gt;&lt;br/&gt; 
  </code></pre>