File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
file /
fgetcsv.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:03 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
various fgetcsv() functionality tests
--FILE--
<?php
$list = array(
'aaa,bbb',
'aaa,"bbb"',
'"aaa","bbb"',
'aaa,bbb',
'"aaa",bbb',
'"aaa", "bbb"',
',',
'aaa,',
',"aaa"',
'"",""',
'"\\"","aaa"',
'"""""",',
'""""",aaa',
'"\\""",aaa',
'aaa,"\\"bbb,ccc',
'aaa,bbb ',
'aaa,"bbb "',
'aaa"aaa","bbb"bbb',
'aaa"aaa""",bbb',
'aaa"\\"a","bbb"'
);
$file = dirname(__FILE__) . 'fgetcsv.csv';
@unlink($file);
foreach ($list as $v) {
$fp = fopen($file, "w");
fwrite($fp, $v . "\n");
fclose($fp);
var_dump(fgetcsv(fopen($file, "r"), 1024));
}
@unlink($file);
?>
--EXPECT--
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(3) "aaa"
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(2) "\""
[1]=>
string(3) "aaa"
}
array(2) {
[0]=>
string(2) """"
[1]=>
string(0) ""
}
array(1) {
[0]=>
string(7) """,aaa
"
}
array(1) {
[0]=>
string(8) "\"",aaa
"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(10) "\"bbb,ccc
"
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(6) "bbb "
}
array(2) {
[0]=>
string(3) "aaa"
[1]=>
string(6) "bbb "
}
array(2) {
[0]=>
string(8) "aaa"aaa""
[1]=>
string(6) "bbbbbb"
}
array(2) {
[0]=>
string(10) "aaa"aaa""""
[1]=>
string(3) "bbb"
}
array(2) {
[0]=>
string(8) "aaa"\"a""
[1]=>
string(3) "bbb"
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>