fputcsv putting quotes where it shouldn't

1k views Asked by At

I'm writing a script to export products to Google Base... the problem is that when I use the following code in stock gets outputted as "in stock" and Google doesn't recognize that, it only recognizes it without the quotes. I don't know of a way to do this without including quotes there.

                        $row = array(
                            'new',
                            $product->getSku().'-'.$vehicle->getId(),
                            'https://www.domain.com/vehicles/'.str_replace(' ', '-', $make->getName()).'/'.str_replace(' ', '-', $model->getName()).'/'.$year.'/'.$product->getId(),
                            $this->tru->config->get('root.cdn.url').'-products/'.$product->getPicture(),
                            $product->getSellPrice(),
                            $title,
                            $year,
                            'in stock',
                            $product->getFCCID(),
                            'Visa,Mastercard,Discover,AmericanExpress',
                            'US::Ground:4.95,CA::Ground:28.95',
                            'small',
                            'Vehicles & Parts > Automotive Locking Systems > Remote Keyless Systems'
                        );

                        fputcsv($output, $row, $seperatorValue);
1

There are 1 answers

0
satrun77 On

I think it is better if you write your own function rather than using fputcsv()

Something in the following lines of code

$output = fopen("path/to/your/file.csv", "a+");

$line = join(',', $row);

fwrite($output, $line);

fclose($output);

Hope this helps