I have a string with this value:
$myValue = "1.099,90";
And I want to replace commas with dots and vice versa. Just like this:
$myNewValue = "1,099.90";
I know that there must be other better ways of doing this, but all I can get is:
$myNewValue = str_replace(",","|",$myValue);
$myNewValue = str_replace(".",",",$myValue);
$myNewValue = str_replace("|",".",$myValue);
This way looks weird and has a bad smell! Is there a cleaner way?
This will get the job done, but you could definitely use preg_replace to come up with a different method as well.
You can also use the str_replace w/ extra | symbol (or anything)...