I\'m trying to pick out numbers with more than two decimals (more than two digits after the decimal separator). I cant\'t figure out why this doesn\'t work:
if (
I know, its an old question, but why not just do:
function onlyDecimals($number, $maxDecimalPlaces = 2) { return $amount == number_format($amount, $maxDecimalPlaces, ".", ""); }
See example and tests: http://sandbox.onlinephpfunctions.com/code/e68143a9ed0b6dfcad9ab294c44fa7e802c39dd0