PHP: get number of decimal digits

Erwin picture Erwin · Mar 12, 2010 · Viewed 65.2k times · Source

Is there a straightforward way of determining the number of decimal places in a(n) integer/double value in PHP? (that is, without using explode)

Answer

ghostdog74 picture ghostdog74 · Mar 12, 2010
$str = "1.23444";
print strlen(substr(strrchr($str, "."), 1));