function biblio_strcsv in Bibliography Module 6
Same name and namespace in other branches
- 6.2 includes/biblio.import.export.inc \biblio_strcsv()
- 7 includes/biblio.import.export.inc \biblio_strcsv()
- 7.2 includes/biblio.import.export.inc \biblio_strcsv()
1 call to biblio_strcsv()
File
- ./
biblio.import.export.inc, line 1315 - Functions that are used to import and export biblio data.
Code
function biblio_strcsv($fields = array(), $delimiter = ',', $enclosure = '"') {
$str = '';
$escape_char = '\\';
foreach ($fields as $value) {
if (strpos($value, $delimiter) !== false || strpos($value, $enclosure) !== false || strpos($value, "\n") !== false || strpos($value, "\r") !== false || strpos($value, "\t") !== false || strpos($value, ' ') !== false) {
$str2 = $enclosure;
$escaped = 0;
$len = strlen($value);
for ($i = 0; $i < $len; $i++) {
if ($value[$i] == $escape_char) {
$escaped = 1;
}
else {
if (!$escaped && $value[$i] == $enclosure) {
$str2 .= $enclosure;
}
else {
$escaped = 0;
}
}
$str2 .= $value[$i];
}
$str2 .= $enclosure;
$str .= $str2 . $delimiter;
}
else {
$str .= $value . $delimiter;
}
}
$str = substr($str, 0, -1);
$str .= "\n";
return $str;
}