title: is this ISBN-10 Checksum calculation in php correct?
body: <p>I have found a PHP script  <a href="https://gist.github.com/r15ch13/5459442" rel="nofollow noreferrer">github ISBN-Calc Routine </a>to perform the ISBN-10 checksum calculation:</p>
  
  <pre><code>&lt;?php
  /**
   * Calculate ISBN checksum
   * 
   * @param string $isbn
   * @return integer
   */
  function isbn_checksum($isbn) {
      $sum = 0; $isbn = str_split(preg_replace('/[^\d]/', '', $isbn));
      foreach($isbn as $key =&gt; $z) {
          if($key &gt;= 12) break;
          $sum += ($key % 2) ? $z * 3 : $z;
      }
      $checksum = (10 - $sum % 10);
      return ($checksum == 10) ? 0 : $checksum;
  }
  </code></pre>
  
  <p>But f.e for my <code>ISBN-10: 0470173424</code>  I get <code>Checksum: 0</code>with this github script.</p>
  
  <p>Accoring to <a href="http://www.hahnlibrary.net/libraries/isbncalc.html" rel="nofollow noreferrer">ISBN online checker</a> the checksum should be 4 as is it in the ISBN. Can anyone here provide me with the correct PHP routine, please?</p>
  
  <p>Thanks</p>