function webform_number_standardize in Webform 7.3
Same name and namespace in other branches
- 6.3 components/number.inc \webform_number_standardize()
- 7.4 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.
$point: The point separator between the whole number and the decimals.
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. Validates the entered values from number components on the client-side form.
File
- components/
number.inc, line 809 - 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;
}