You are here

function webform_number_standardize in Webform 7.4

Same name and namespace in other branches
  1. 6.3 components/number.inc \webform_number_standardize()
  2. 7.3 components/number.inc \webform_number_standardize()

Given a number, convert it to string compatible with a PHP float.

Parameters

string $value: The string value to be standardized into a numeric string.

string $point: The point separator between the whole number and the decimals.

Return value

string The converted number.

2 calls to webform_number_standardize()
_webform_submit_number in components/number.inc
Implements _webform_submit_component().
_webform_validate_number in components/number.inc
A Drupal Form API Validation function.

File

components/number.inc, line 892
Webform module number component.

Code

function webform_number_standardize($value, $point) {

  // For simplicity, strip everything that's not the decimal point.
  $value = preg_replace('/[^\\-0-9' . preg_quote($point, '/') . ']/', '', $value);

  // Convert the decimal point to a period.
  $value = str_replace($point, '.', $value);
  return $value;
}