Question

I'm trying to write the tab-delimited content of a variable to XML like this:

$tsvData = str_getcsv($input, "\t");
foreach($tsvData as $line => $row) {
    if($line > 0) {
        $xmlWriter->writeElement('NAME', $row[0]);
        $xmlWriter->writeElement('CAKE', $row[1]);
        $xmlWriter->writeElement('BODYPART', $row[2]);
    }
}

But it's only writing one character per XML tag instead of everything between each tab. When I use SplFileObject, geting the same tsv data but from a file, it works. What am I doing wrong with the str_getcsv function?

Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top