in reply to 0 illegal modulus?
well, you could override the modulus operator if you prefer, and use an idiom like
$ans = ($y*1) ? $x % $y : 0; [download]