Skip to content

Instantly share code, notes, and snippets.

@tristar500
Created December 7, 2013 22:52
Show Gist options
  • Save tristar500/7850853 to your computer and use it in GitHub Desktop.
Save tristar500/7850853 to your computer and use it in GitHub Desktop.
Convert string value with commas into a float
$val = "1,234,988.56";
$num = floatval(str_replace(",","",$val));
echo $num;
// returns - 1234988.56
@giovannipds
Copy link

In case of the format "1.234.988,56", you can use (float) str_replace(['.', ','], ['', '.'], $value);.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment