1--TEST--
2various fputcsv() functionality tests
3--CREDITS--
4Lee Leathers <leeleathers@gmail.com>
5--FILE--
6<?php
7
8$list = array (
9  0 => 'aaa,bbb',
10  1 => 'aaa,"bbb"',
11  2 => '"aaa","bbb"',
12  3 => 'aaa,bbb',
13  4 => '"aaa",bbb',
14  5 => '"aaa",   "bbb"',
15  6 => ',',
16  7 => 'aaa,',
17  8 => ',"aaa"',
18  9 => '"",""',
19  10 => '"""""",',
20  11 => '""""",aaa',
21  12 => 'aaa,bbb   ',
22  13 => 'aaa,"bbb   "',
23  14 => 'aaa"aaa","bbb"bbb',
24  15 => 'aaa"aaa""",bbb',
25);
26
27$file = __DIR__ . '/fputcsv_variation15.csv';
28
29$fp = fopen($file, "w");
30foreach ($list as $v) {
31    fputcsv($fp, explode(',', $v), ',', '"', '');
32}
33fclose($fp);
34
35$res = file($file);
36foreach($res as &$val)
37{
38    $val = substr($val, 0, -1);
39}
40echo '$list = ';var_export($res);echo ";\n";
41
42$fp = fopen($file, "r");
43$res = array();
44while($l=fgetcsv($fp, 0, ',', '"', ''))
45{
46    $res[] = join(',',$l);
47}
48fclose($fp);
49
50echo '$list = ';var_export($res);echo ";\n";
51
52?>
53--CLEAN--
54<?php
55$file = __DIR__ . '/fputcsv_variation15.csv';
56@unlink($file);
57?>
58--EXPECT--
59$list = array (
60  0 => 'aaa,bbb',
61  1 => 'aaa,"""bbb"""',
62  2 => '"""aaa""","""bbb"""',
63  3 => 'aaa,bbb',
64  4 => '"""aaa""",bbb',
65  5 => '"""aaa""","   ""bbb"""',
66  6 => ',',
67  7 => 'aaa,',
68  8 => ',"""aaa"""',
69  9 => '"""""",""""""',
70  10 => '"""""""""""""",',
71  11 => '"""""""""""",aaa',
72  12 => 'aaa,"bbb   "',
73  13 => 'aaa,"""bbb   """',
74  14 => '"aaa""aaa""","""bbb""bbb"',
75  15 => '"aaa""aaa""""""",bbb',
76);
77$list = array (
78  0 => 'aaa,bbb',
79  1 => 'aaa,"bbb"',
80  2 => '"aaa","bbb"',
81  3 => 'aaa,bbb',
82  4 => '"aaa",bbb',
83  5 => '"aaa",   "bbb"',
84  6 => ',',
85  7 => 'aaa,',
86  8 => ',"aaa"',
87  9 => '"",""',
88  10 => '"""""",',
89  11 => '""""",aaa',
90  12 => 'aaa,bbb   ',
91  13 => 'aaa,"bbb   "',
92  14 => 'aaa"aaa","bbb"bbb',
93  15 => 'aaa"aaa""",bbb',
94);
95