3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $map = [ 6 => 215601, 11 => 3260461, 7 => 210282, 11 => 3258941 ]; foreach($map as $key => $value) { $p = str_pad($key, 3, '0', STR_PAD_LEFT) . str_pad($value, 10, '0', STR_PAD_LEFT); echo "\n"; echo $p; $ctr = 22; $ctro = '0' . substr($p,1,2) . substr($p,6); echo "\n"; echo $ctro; for ($i=0; $i <= 8; $i+=2) { $ctr = $ctr + 3*(int)substr($ctro,$i,1) + (int)substr($ctro,(1+$i),1); } echo "\n"; echo $ctr; $ctr = (10 - ($ctr % 10)) % 10; echo "\n"; echo "Key = " . $ctr; }
based on 2CgmF
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3
0060000215601 0060215601 69 Key = 1 0110003258941 0113258941 86 Key = 4 0070000210282 0070210282 78 Key = 2