Answer the question
In order to leave comments, you need to log in
How to extract thousandths, hundredths, tenths, units and the number after the comma from a number in PHP?
There is some number, let's say 6284.81 .
How in PHP to "extract" thousandths, hundredths, tenths, units and the number after the decimal point from this number? Once extracted, assign them to variables such as $thousandths (thousandths), $hundredths (hundredths), $tenths (tenths), $units (units), and $float_num (the number after the decimal point).
Result:
$thousandths should be 6000
$hundredths should be 200
$tenths should be 80
$units should be 4
$float_num should be 81
Is there a special function in PHP for such "separation" by variables? Thanks in advance
Answer the question
In order to leave comments, you need to log in
no
, you yourself will have to calculate the result of an integer division by the corresponding power of ten
, the answer is easily searched for by a search engine!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question