php - Decimal number with only 10 digits for the integer and 6 for the decimals? -


Suppose that the number given to me is 47.50, how can I allow the integer for 10 digits only and for decimal 6 as it is 0000000047.500000 or another example: from 3475.95 it is 0000003475.950000 < p> // Is it ok to use the strappad? How can I use it?
  $ amount = straw_pad (3475.95, 10, '0', STR_PAD_LEFT);    

is not the most beautiful approach, but hey, we're talking about the script Are you, right?

  & lt ;? Php $ value = 47.56; Echo Sprintf ('% s.% S', str_pad (int) $ value, 10, '0', STR_PAD_LEFT), str_pad (substr ($ value- (int) $ value, 2), 6, '0' STR_PAD_RIGHT) ); ? & Gt;   

Sorry, could not resist. But obviously, the correct solution was Mark Baker in his comment above: sprintf ("% 016.6f", 3475.95); ...

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -