title: display different prefix according gender in codeigniter php
body: <pre class="lang-php prettyprint-override"><code>$all_categories = get_cats($cat);
  echo "&amp;nbsp&amp;nbsp"."Sons";
  
  for ($i=0;$i&lt;sizeof($all_categories);$i++) {     
      $arr = get_gender($cat);
  
      if ($arr[$i]=='0') {
          echo "&amp;nbsp&amp;nbsp".$all_categories[$i].",";
      }  
  } 
  
  echo "&amp;nbsp&amp;nbsp"."Daughters";
  
  for ($i=0;$i&lt;sizeof($all_categories);$i++) {     
      $arr = get_gender($cat);
  
      if ($arr[$i]=='1') {
          echo "&amp;nbsp&amp;nbsp".$all_categories[$i].",";
      }
  } 
  </code></pre>
  
  <p>In <code>$all_categories</code> I'm getting all child of a given id and <code>get_cats</code> and <code>get_gender</code> are functions.</p>
  
  <p><code>0</code> is for male and <code>1</code> is for female. I want to display the word "Sons" first then their names and then count of sons and then word "Daughters" and their names and count of daughters.</p>
  
  <p>Now I am displaying the word "sons" then their names and then the word "daughters" and their names but the words "sons" and "daughters" are being displayed even if given id has no children.</p>