title: PHP round to integer
body: <p>I want to round a number and I need a proper integer because I want to use it as an array key. The first "solution" that comes to mind is:</p>
  
  <pre><code>$key = (int)round($number)
  </code></pre>
  
  <p>However, I am unsure if this will always work. As far as I know <code>(int)</code> just truncates any decimals and since <code>round($number)</code> returns a float with theoretically limited precision, is it possible that <code>round($number)</code> returns something like 7.999999... and then <code>$key</code> is 7 instead of 8?</p>
  
  <p>If this problem actually exists (I don't know how to test for it), how can it be solved? Maybe:</p>
  
  <pre><code>$key = (int)(round($number) + 0.0000000000000000001) // number of zeros chosen arbitrarily
  </code></pre>
  
  <p>Is there a better solution than this?</p>