If you're using PHP5.3 or above, you can use numfmt_parse to do "a reversed number_format". If you're not, you stuck with replacing the occurrances with preg_replace/str_replace.
Using str_replace() to remove the dots is not overkill.
$string_number = '1.512.523,55';
// NOTE: You don't really have to use floatval() here, it's just to prove that it's a legitimate float value.
$number = floatval(str_replace(',', '.', str_replace('.', '', $string_number)));
// At this point, $number is a "natural" float.
print $number;
This is almost certainly the least CPU-intensive way you can do this, and odds are that even if you use some fancy function to do it, that this is what it does under the hood.
This works for all kind of inputs (American or european style)
echo floatvalue('1.325.125,54'); // The output is 1325125.54
echo floatvalue('1,325,125.54'); // The output is 1325125.54
echo floatvalue('59,95'); // The output is 59.95
echo floatvalue('12.000,30'); // The output is 12000.30
echo floatvalue('12,000.30'); // The output is 12000.30
$test='2,345.67';
// OOP Version
$numberFormatter=new NumberFormatter('en-AU',NumberFormatter::DECIMAL);
$number=$numberFormatter->parse($test);
print $number;
// Procedural Version
$numberFormatter=numfmt_create('en_AU',NumberFormatter::DECIMAL);
$number=numfmt_parse($numberFormatter,$test);
print $number;
Of course your locale may very.
Not sure why anyone would opt for the procedural version.
Note that one major difference between NumberFormat and the str_replace type solutions is that NumberFormatter is sensitive to where you put your thousands and decimal characters; using 1,2345.00 won’t work.