0

I need to get the float of a string. But am facing problem with 0 decimal values i.e -

floatval("10000.01") gives 10000.01

but

floatval("10000.00") is giving 10000

I need the later value as 10000.00 too. What am I missing?

1

1 Answer 1

1

Try to use number_format() function instead for the same:

$numberValue = "10000.00";
$numberString = number_format($numberValue, 2);
Sign up to request clarification or add additional context in comments.

1 Comment

This is converting it to 10,000. I don't need the commas('), just a simple plain floating number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.