E
E
Eugene2015-07-01 20:02:23
PHP
Eugene, 2015-07-01 20:02:23

How to create a different separator when creating a CSV?

An extract is generated from the server into a CSV file. But by default, the separator is a comma.
How can I change it to a semicolon. Found in the documentation:

foreach ($list as $line) {
    fputcsv($fp, split(';', $line));
}

But when adding split, nothing is unloaded for me at all ...
Initially, my code is:
foreach ($arrayData as $fields) {
  fputcsv($fp, $fields);
}
fclose($fp);

arrayData array, like:
Array
(
    [0] => Array
        (
            [id] => 0-1
            [title] => 0-2
            [h1] => 0-3       
        )
    [1] => Array
        (
            (
            [id] => 1-1
            [title] =>1-2
            [h1] => 1-3   
        )
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2015-07-01
@atachrus

Looked
bad id1.php.net/manual/ru/function.fputcsv.php
int fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape_char = "\" ]]] )
fputcsv($fp, $fields, ';');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question