You are here

protected function SimpleMathField::removeSeparator in Views Simple Math Field 8.2

Remove thousands marker.

Parameters

$field:

$data:

Return value

mixed

1 call to SimpleMathField::removeSeparator()
SimpleMathField::getFieldValue in src/Plugin/views/field/SimpleMathField.php
Get the value of a simple math field.

File

src/Plugin/views/field/SimpleMathField.php, line 241
Defines Drupal\views_simple_math_field\Plugin\views\field\SimpleMathField.

Class

SimpleMathField
Field handler to complete mathematical operation.

Namespace

Drupal\views_simple_math_field\Plugin\views\field

Code

protected function removeSeparator($field, $data) {
  if (!empty($this->view->field[$field]->options['separator'])) {
    $separator = $this->view->field[$field]->options['separator'];
  }
  if (!empty($separator)) {
    if (strpos($data, $separator)) {
      $data = str_replace($separator, '', $data);
    }
  }
  else {
    if (strpos($data, ',')) {
      $data = str_replace(',', '', $data);
    }
    if (strpos($data, ' ')) {
      $data = str_replace(' ', '', $data);
    }
  }
  return $data;
}