Core
3.2
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
WriteCsv.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @package FDL
5
*/
6
7
namespace
Dcp;
8
9
if
(! defined(
"ALTSEPCHAR"
)) {
10
define(
"ALTSEPCHAR"
,
' --- '
);
11
}
12
class
WriteCsv
13
{
14
15
static
public
$enclosure =
''
;
16
static
public
$separator =
';'
;
17
static
public
$encoding =
"utf-8"
;
18
/**
19
* @param resource $handler
20
* @param array $data
21
*/
22
static
function
fput
($handler, array
$data
)
23
{
24
25
if
(empty(self::$enclosure)) {
26
//str_replace(SEPCHAR, ALTSEPCHAR
27
$cleanData = array_map(
function
($item)
28
{
29
return
str_replace(array(
30
"\n"
,
31
self::$separator,
32
"\r"
33
) , array(
34
"\\n"
,
35
ALTSEPCHAR
,
36
""
37
) , $item);
38
}
39
,
$data
);
40
$s
= implode(self::$separator, $cleanData);
41
if
(self::$encoding ===
"iso8859-15"
) {
42
$s = utf8_decode($s);
43
}
44
fputs($handler, $s .
"\n"
);
45
}
else
{
46
if
(self::$encoding ===
"iso8859-15"
) {
47
$data = array_map(
function
($cell)
48
{
49
return
utf8_decode($cell);
50
}
51
,
$data
);
52
}
53
fputcsv($handler, $data, self::$separator, self::$enclosure);
54
}
55
}
56
}
$s
if($famId) $s
Definition:
refreshDocuments.php:112
ALTSEPCHAR
const ALTSEPCHAR
Definition:
import_file.php:25
Dcp\WriteCsv\fput
static fput($handler, array $data)
Definition:
WriteCsv.php:22
Dcp\WriteCsv
Definition:
WriteCsv.php:12
$data
$data
Definition:
fdl_sendmail.php:40
← centre documentaire
© anakeen