3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _generateChecksum($eanCodeWithoutChecksum) { $key = 0; $mult = array(1, 3); for ($i = 0; $i < strlen($eanCodeWithoutChecksum); $i++) $key += substr($eanCodeWithoutChecksum, $i, 1) * $mult[$i % 2]; $key = 10 - ( $key % 10 ); if ($key == 10) $key = 0; return $key; } echo _generateChecksum(205240000003);

preferences:
40.65 ms | 402 KiB | 5 Q