#34265 [Opn->Fbk]: fgetcsv with length 0 work in other way than length specified
| From: | sniper@php.net | Date: | Fri, 26 Aug 2005 14:34:46 +0000 |
| Subject: | #34265 [Opn->Fbk]: fgetcsv with length 0 work in other way than length specified | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-84032@lists.php.net to get a copy of this message | ||
ID: 34265
Updated by: sniper@php.net
Reported By: mdv at inyourpocket dot com
-Status: Open
+Status: Feedback
Bug Type: Strings related
Operating System: Debian
PHP Version: 5.0.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-08-26 09:49:27] mdv at inyourpocket dot com
FILE (contains 1 line):
0;;;;0.00;0.00
<?php
$fd = fopen('file', 'r');
$t = fgetcsv($fd, 0, ';');
var_dump($t);
?>
returns:
array(1) {
[0]=>
string(1) "0"
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(1) {
[0]=>
string(1) "0"
}
array(1) {
[0]=>
string(1) "."
}
array(1) {
[0]=>
string(1) "0"
}
array(1) {
[0]=>
string(1) "0"
}
array(2) {
[0]=>
string(0) ""
[1]=>
string(0) ""
}
array(1) {
[0]=>
string(1) "0"
}
array(1) {
[0]=>
string(1) "."
}
array(1) {
[0]=>
string(1) "0"
}
array(1) {
[0]=>
string(1) "0"
}
array(1) {
[0]=>
string(0) ""
}
------------------------------------------------------------------------
[2005-08-26 08:53:29] mdv at inyourpocket dot com
Description:
------------
when length is 0 function parse strange
notice "[0] => X" (there is space before X in actual result) - hexa is
0x00
simple when getting same line:
fgetcsv($fd, 0, ';') != fgetcsv($fd, 4096, ';')
Reproduce code:
---------------
FILE (contains only 1 line for example):
"X";"Y";"Zv";"Text";"H";"S";"R";"n";"I";"Ob";"P";"Roz";"Pdj"
<?php
$fd = fopen('file', 'r');
$t = fgetcsv($fd, 0, ';');
echo '<pre>';
var_dump($t);
echo '</pre>';
?>
Expected result:
----------------
array(13) {
[0]=>
string(1) "X"
[1]=>
string(1) "Y"
[2]=>
string(2) "Zv"
[3]=>
string(4) "Text"
[4]=>
string(1) "H"
[5]=>
string(1) "S"
[6]=>
string(1) "R"
[7]=>
string(1) "n"
[8]=>
string(1) "I"
[9]=>
string(2) "Ob"
[10]=>
string(1) "P"
[11]=>
string(3) "Roz"
[12]=>
string(3) "Pdj"
}
Actual result:
--------------
array(13) {
[0]=>
string(2) " X"
[1]=>
string(1) "Y"
[2]=>
string(2) "Zv"
[3]=>
string(4) "Text"
[4]=>
string(1) "H"
[5]=>
string(1) "S"
[6]=>
string(1) "R"
[7]=>
string(1) "n"
[8]=>
string(1) "I"
[9]=>
string(2) "Ob"
[10]=>
string(1) "P"
[11]=>
string(3) "Roz"
[12]=>
string(3) "Pdj"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34265&edit=1