Basically I'm trying to group my arrays like this:
Shopping
   Amazon
Social
   Amoeblo
   American express
By using below PHP code:
<?php
echo '<ul id="list"><h2 class="searchresults"></h2>';
foreach($records as $catval) {
  $sitechar = $catval->site_category; 
  echo '<h3 id="disappear">'. strtoupper($sitechar) .'</h3>';       
  echo '<li class="siteli"><a href="#" class="add">'; 
  echo '<p id="text-site">'.$catval->site_name. '</p></a>';
  echo '</li>'; 
}
echo '</ul>';
?>
But I'm getting values only like below.
Shopping
       Amazon
Social
       Amoeblo
Social
       American express
I'm not getting the exact PHP sorting to use for this.
 
     
     
    