Convert string to numeric value in PHP

0

I have the following string: $s = '9876543210.12345';

I need to convert this string to a value of a numeric type.

I tried with (int) $s only it removes the decimal places and returns like this: 9876543210 .

I tried with (float) $s and it returns me without the last digit like this: 9876543210.1234 .

I also tried using the number_format but the return was of type string .

How can I convert this value to a numeric type without losing any decimal places?

    
asked by anonymous 01.11.2017 / 12:43

1 answer

0

It looks like this:

You'llgetthefollowingresult:

    
02.11.2017 / 00:41