Something you would not expect but need to be aware of when you\'re dealing with floating point numbers in php
You're casting $i (3287) to a string and then to an int, so the result stays 3287. If you cast $i to an int you'll get 3286, and then if you cast it to a string you'll have what you want.
$i
Try echo (string) (int) $i
echo (string) (int) $i