3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $prefix = (string) 1234; $id = (string) 3; $number = $prefix . str_repeat('0', 12 - strlen($prefix) - strlen($id)) . $id; $odd = true; $checksum = 0; $key = range(0, 9); for ($i = strlen($number); $i > 0; $i--) { $checksum += $key[$number[$i - 1]] * (($odd = !$odd) ? 3 : 1); } $checksum = 10 - $checksum % 10; $checksum = ($checksum == 10) ? 0 : $checksum; echo $number . $checksum;
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
1234000000039