C
C
Cyril2018-02-08 15:39:30
PHP
Cyril, 2018-02-08 15:39:30

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

2 answer(s)
L
Lazy @BojackHorseman PHP, 2018-02-08
Tag

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!

L
Lone Ice, 2018-02-08
@daemonhk

This is for you to determine the value after the decimal point, everything else is determined by dividing by 1000, 100, 10 and calculating the remainder.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question