You are here

function uc_csv_clean_filename in Ubercart CSV 7.2

Same name and namespace in other branches
  1. 6.2 uc_csv.module \uc_csv_clean_filename()

Clean the file name of the report

Prevents spaces and oddball characters from appearing in report filenames

1 call to uc_csv_clean_filename()
uc_csv_select_report_to_export_submit in ./uc_csv.module
Put together an export based on the report id

File

./uc_csv.module, line 633

Code

function uc_csv_clean_filename($str, $replace = array(), $delimiter = '-') {
  setlocale(LC_ALL, 'en_US.UTF8');
  if (!empty($replace)) {
    $str = str_replace((array) $replace, ' ', $str);
  }
  $clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
  $clean = preg_replace("/[^a-zA-Z0-9\\/_|+ -]/", '', $clean);
  $clean = strtolower(trim($clean, '-'));
  $clean = preg_replace("/[\\/_|+ -]+/", $delimiter, $clean);
  return $clean;
}