Try this.i used number_format() for this
<?php
$number = "1.234,56";
$number = str_replace(array('.',','), array('','.'), $number);
echo number_format($number, 2, '.', ',');
You can also use money_format() function.Note that it won't work on windows.
Here is another method.
<?php
$str = "1.234,56";
$rp1 = '.';
$rp2 = ',';
//you might want to create a function for this.
if(false===strpos($str, '@')){
$str = str_replace($rp1, '@', $str);
$str = str_replace($rp2, $rp1, $str);
$str = str_replace('@', $rp2, $str);
}
echo $str;
You can also use a unique string like #!MYSEP!#