You are here

function vap_num in Views Aggregator Plus 7

Same name and namespace in other branches
  1. 8 views_aggregator_functions.inc \vap_num()

Function to extract a double from a string, auto-skipping non-numeric chars.

Comma's and spaces are ignored. Scientific notation, e.g., 1.23E-45, is NOT supported, it will return 1.23

Parameters

string $string: A string representatin of a double-precision floating point number.

Return value

mixed Returns double or FALSE, if no number could be found in the string.

5 calls to vap_num()
views_aggregator_average in ./views_aggregator_functions.inc
Aggregates a field group as the average amongst its members.
views_aggregator_median in ./views_aggregator_functions.inc
Aggregates a field group as the median across its members.
views_aggregator_percentage in views_aggregator_more_functions/views_aggregator_more_functions.module
Aggregates a field group total as the percentage of the column total.
views_aggregator_plugin_style_table::get_cell in views/views_aggregator_plugin_style_table.inc
Returns the raw or rendered result at the intersection of column and row.
views_aggregator_sum in ./views_aggregator_functions.inc
Aggregates a field group as the sum of its members.

File

./views_aggregator_functions.inc, line 726
views_aggregator_functions.inc

Code

function vap_num($string) {

  // Strip out any spaces and thousand makers.
  $stripped = str_replace(array(
    ' ',
    ',',
  ), '', $string);
  return preg_match('/[-+]?\\d*\\.?\\d+/', $stripped, $matches) ? (double) $matches[0] : FALSE;
}