title: Rounding in PHP to achieve 100%
body: <p>I need to total the number of clicks over 10 links on my page and then figure out the percentage of people that clicked each. This is easy division, but how do I make sure that I get a round 100% at the end.</p>
  
  <p>I want to use the below code, but am worried that a situation could arise where the percentages do not tally to 100% as this function simply removes the numbers after the period.</p>
  
  <pre><code>function percent($num_amount, $num_total) {
  $count1 = $num_amount / $num_total;
  $count2 = $count1 * 100;
  $count = number_format($count2, 0);
  echo $count;
  }
  </code></pre>
  
  <p>Any advice would be much appreciated.</p>