<?php
/**
* my_bcmod - 取得餘數(bcmod 的替代方案)
* string my_bcmod ( string left_operand, int modulus )
* left_operand 可以非常大,但要注意 modulus :(
* 作者:Andrius Baranauskas 和 Laurynas Butkus :) 維爾紐斯,立陶宛
**/
function my_bcmod( $x, $y )
{
// 一次取多少個數字?小心不要超過 (int) 的範圍
$take = 5;
$mod = '';
do
{
$a = (int)$mod.substr( $x, 0, $take );
$x = substr( $x, $take );
$mod = $a % $y;
}
while ( strlen($x) );
return (int)$mod;
}
// 範例
echo my_bcmod( "7044060001970316212900", 150 );
?>