PHP 8.5.0 Alpha 4 available for testing

Voting

: zero plus four?
(Example: nine)

The Note You're Voting On

info at marc-gutt dot de
16 years ago
<?php
function floatvalue($value) {
return
floatval(preg_replace('#^([-]*[0-9\.,\' ]+?)((\.|,){1}([0-9-]{1,2}))*$#e', "str_replace(array('.', ',', \"'\", ' '), '', '\\1') . '.\\4'", $value));
}
?>

It is much shorter and able to handle those one, too:
xx,-
xx,--
xx'xxx,xx

After using floatvalue() you can go forward with number_format() as usual.

<< Back to user notes page

To Top