Уже смог реализовать, если кому интересно, то вот:
$numbers = 2;
for ($i = 0; $i < 14; $i++)
{
$numbers .= mt_rand(0, 9);
}
$l_1 = ($numbers[0] * 2) >= 10 ? ($numbers[0] * 2) - 9 : $numbers[0] * 2;
$l_2 = ($numbers[2] * 2) >= 10 ? ($numbers[2] * 2) - 9 : $numbers[2] * 2;
$l_3 = ($numbers[4] * 2) >= 10 ? ($numbers[4] * 2) - 9 : $numbers[4] * 2;
$l_4 = ($numbers[6] * 2) >= 10 ? ($numbers[6] * 2) - 9 : $numbers[6] * 2;
$l_5 = ($numbers[8] * 2) >= 10 ? ($numbers[8] * 2) - 9 : $numbers[8] * 2;
$l_6 = ($numbers[10] * 2) >= 10 ? ($numbers[10] * 2) - 9 : $numbers[10] * 2;
$l_7 = ($numbers[12] * 2) >= 10 ? ($numbers[12] * 2) - 9 : $numbers[12] * 2;
$l_8 = ($numbers[14] * 2) >= 10 ? ($numbers[14] * 2) - 9 : $numbers[14] * 2;
$str = $l_1 + $l_2 + $l_3 + $l_4 + $l_5 + $l_6 + $l_7 + $l_8;
$str = $str + $numbers[0] + $numbers[2] + $numbers[4] + $numbers[6] + $numbers[8] + $numbers[10] + $numbers[12] + $numbers[14];
$l = 0;
for (; ($str % 10) !== 0; $str++) $l++;
$numbers .= $l;