<?php

function emsnum($ems, $num) {
$fri = substr($ems, 2, 8);
$head = substr($ems, 0, 2);
$tail = substr($ems, -2);
for ($i = 1; $i <= $num; $i++) {
$num3 = substr($fri, 0, 1);
$num4 = substr($fri, 1, 1);
$num5 = substr($fri, 2, 1);
$num6 = substr($fri, 3, 1);
$num7 = substr($fri, 4, 1);
$num8 = substr($fri, 5, 1);
$num9 = substr($fri, 6, 1);
$num0 = substr($fri, 7, 1);
$mid = 8 * $num3 + 6 * $num4 + 4 * $num5 + 2 * $num6 + 3 * $num7 + 5 * $num8 + 9 * $num9 + 7 * $num0;
$res = 11 - ($mid % 11);
if ($res == 10) {
$res = 0;
}
if ($res == 11) {
$res = 5;
}
$emsres[$i] = $head . $fri . $res . $tail;
$fri+= 1;
$len = strlen($fri);
if ($len < 8) {
for ($j = $len; $j < 8; $j++) {
$fri = "0" . $fri;
}
}
}
return $emsres;
}
$arr = emsnum("1014662951580", "20");
echo "<pre>";
var_dump($arr);
die;
?>
05-12 05:09