Skip to content

Instantly share code, notes, and snippets.

@salipro4ever
Created November 4, 2016 07:31
Show Gist options
  • Save salipro4ever/c868b1e126f73f554d76b375ca325fcd to your computer and use it in GitHub Desktop.
Save salipro4ever/c868b1e126f73f554d76b375ca325fcd to your computer and use it in GitHub Desktop.
PHP Helpers
/**
* Convert number string to number
* @param $num string 1,251.11
* @return numberic
*/
function reverse_number_format(&$num)
{
return $num = (float)str_replace(',', '', trim($num));
}
--------------
$number= '$ 1,989.34';
$number = filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
//1989.34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment