File tree 1 file changed +124
-0
lines changed
1 file changed +124
-0
lines changed Original file line number Diff line number Diff line change 1
1
# php-parse-csv
2
2
Parse CSV function in php
3
+
4
+ ## Use:
5
+ ```` php
6
+ <?php
7
+ require('parseCSV.php');
8
+
9
+ $withTitles = true;
10
+ $data = parseCsv("myfile.csv", $withTitles);
11
+ print_r($data);
12
+ ````
13
+ ### Result:
14
+ ````
15
+ Array
16
+ (
17
+ [0] => Array
18
+ (
19
+ [name] => John Doe
20
+ [email] => test@example.com
21
+ [phone] => +972501234567
22
+ [course] => Array
23
+ (
24
+ [0] => course 3
25
+ [1] => course 4
26
+ )
27
+
28
+ )
29
+
30
+ [1] => Array
31
+ (
32
+ [name] => John Doe 2
33
+ [email] => test2@example.com
34
+ [phone] => +972501234568
35
+ [course] => Array
36
+ (
37
+ [0] => course 2
38
+ [1] => course 6
39
+ )
40
+
41
+ )
42
+ )
43
+ ````
44
+
45
+ ## Example
46
+ parse with titles:
47
+ ```` php
48
+ $data = parseCsv("myfile.csv");
49
+ print_r($data);
50
+ ````
51
+ ### Result:
52
+ ````
53
+ Array
54
+ (
55
+ [0] => Array
56
+ (
57
+ [name] => John Doe
58
+ [email] => test@example.com
59
+ [phone] => +972501234567
60
+ [course] => Array
61
+ (
62
+ [0] => course 3
63
+ [1] => course 4
64
+ )
65
+
66
+ )
67
+
68
+ [1] => Array
69
+ (
70
+ [name] => John Doe 2
71
+ [email] => test2@example.com
72
+ [phone] => +972501234568
73
+ [course] => Array
74
+ (
75
+ [0] => course 2
76
+ [1] => course 6
77
+ )
78
+
79
+ )
80
+ )
81
+ ````
82
+
83
+ parse without titles:
84
+ ```` php
85
+ $data = parseCsv("myfile.csv", false);
86
+ print_r($data);
87
+ ````
88
+ ### Result:
89
+ ````
90
+ Array
91
+ (
92
+ [0] => Array
93
+ (
94
+ [0] => name
95
+ [1] => email
96
+ [2] => phone
97
+ [3] => course
98
+
99
+ )
100
+ [1] => Array
101
+ (
102
+ [0] => John Doe
103
+ [1] => test@example.com
104
+ [2] => +972501234567
105
+ [3] => course 3
106
+ [4] => course 4
107
+
108
+ )
109
+
110
+ [2] => Array
111
+ (
112
+ [0] => John Doe 2
113
+ [1] => test2@example.com
114
+ [2] => +972501234568
115
+ [3] => course 2
116
+ [4] => course 6
117
+
118
+ )
119
+ )
120
+ ````
121
+
122
+ ## Contact
123
+ [ parsecsv@yehudae.net ] ( mailto:parsecsv@yehudae.net )
124
+
125
+ ## License
126
+ MIT
You can’t perform that action at this time.
0 commit comments