code: public function sanitize($data)
      {
          if (! is_array($data)) {
              return filter_var(trim($data), FILTER_SANITIZE_STRING);
          }
  
          foreach ($data as $key => $value) {
              $data[$key] = filter_var($value, FILTER_SANITIZE_STRING);
          }
          return $data;
      }
docs: Sanitizing Data
  
  @param string $data
  
  @return string