0

I'm trying to convert a string number like 14,767 or 96,812.10 or 6,780,766.50 but if I use (double)$fildOfDataBase or (float)$fildOfDataBase this put a integer format as 14 o 96 and I don't know why, so my question is how can i convert a string to a number format, hope some one can help me I'm using laravel 8

1

1 Answer 1

1

You need to remove the thousands separator first

(float)str_replace(',', '', $fildOfDataBase);

Another more "strict" way to do it is to use numfmt_parse

//in your case use the en_EN format
$fmt = numfmt_create( 'en_EN', NumberFormatter::DECIMAL );
numfmt_parse($fmt, $fildOfDataBase);
Sign up to request clarification or add additional context in comments.

Comments

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.