Skip to content

Instantly share code, notes, and snippets.

@manniru
Forked from tristar500/String to Float.php
Created February 9, 2022 21:45
Show Gist options
  • Save manniru/15373460d21fc807c158aa4e8ded068b to your computer and use it in GitHub Desktop.
Save manniru/15373460d21fc807c158aa4e8ded068b 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment