unitaccessionnumber; $helperAr ['ipen'] = $doc->ipen; $helperAr ['institution'] = $doc->institution; $helperAr ['accessionStatus'] = $doc->disposition; $helperAr ['fullScientificName'] = $doc->fullScientificName; $helperAr ['family'] = $doc->familyName; $helperAr ['country'] = $doc->country; $helperAr ['sea'] = $doc->sea; $helperAr ['locality'] = $doc->locality; $helperAr ['latitude'] = $doc->latitude; $helperAr ['longitude'] = $doc->longitude; $helperAr ['collectors'] = $doc->collectors; $helperAr ['collectiondate'] = $doc->gatheringdate; $helperAr ['collectornumber'] = $doc->collectornumber; $helperAr ['material'] = $doc->sampletype; // write the line to the file. Replace all existing commas by semicolons $line = ''; foreach ( $firstLine as $value ) { $rep = str_replace ( ",", ";", $helperAr [$value] ); $line .= mb_convert_encoding($rep, 'UTF-16LE', 'UTF-8') . ','; } //echo $line; fwrite ( $handle, $line . "\r\n" ); } } } catch ( Exception $e ) { // TODO } return [$filename]; } }