title: Display different prefix and suffix in CodeIgniter PHP
body: <pre><code>$all_categories=get_cats($cat);
  $headingPrinted = false;
  $childCount = 0;
  for($i=0;$i&lt;sizeof($all_categories);$i++)
  {    
    $arr=get_gender($cat);
    if($arr[$i]=='0')
    {
      if (!$headingPrinted) {
        echo "&amp;nbsp&amp;nbsp"."Sons:";
        $headingPrinted = true;
      }  
      echo "&amp;nbsp&amp;nbsp".$all_categories[$i].",";
      $childCount++;
    }
  } 
  
  if ($childCount &gt;= 3) {
    echo $childCount,  $childCount == 1 ;  
  } 
  else {
    // you may want to do something if none found
  }
  
  $headingPrinted = false;
  $childCount = 0;
  
  for($i=0;$i&lt;sizeof($all_categories);$i++)
  {    
    $arr=get_gender($cat);
    if($arr[$i]=='1'){
      if (!$headingPrinted) {
        echo "&amp;nbsp&amp;nbsp"."Daughters:";
        $headingPrinted = true;
      }  
      echo "&amp;nbsp&amp;nbsp".$all_categories[$i].",";
      $childCount++;
    }
  } 
  if ($childCount &gt;= 3) {
    echo $childCount,  $childCount == 1 ;  
  } 
  else {
    // you may want to do something if none found
  }
  </code></pre>
  
  <p>I am displaying the word "Sons" then their names then their count and the word "daughters" then their names then count. I want to display like this:</p>
  
  <blockquote>
    <p>Sons: a,b,c,d:4;<br>
    Daughters: p,q,r,s:4;</p>
  </blockquote>
  
  <p><code>$all_categories</code> is an array in which I'm getting all children of given ID and <code>get_gender</code> and <code>get_cats</code> are functions.</p>
  
  <p>Now I'm displaying:</p>
  
  <blockquote>
    <p>a,b,c,d, :4;</p>
  </blockquote>
  
  <p>I want to display count only if:</p>
  
  <ul>
  <li>count of sons is greater than 2 and same for daughters.  </li>
  <li>boys count is 1 then the word "Sons:"a; and same for daughters.  </li>
  <li>boys count is 2 then the word "Sons:" a,b; and same for daughters.  </li>
  <li>boys count is greater than 2 then the word "Sons:" a,b,c:3; and same for daughters.  </li>
  </ul>
  
  <p>I want to display result same like above I said. Thanks in advance
  Anyone tried this...</p>