ID: 12337
Updated by: [EMAIL PROTECTED]
-Summary: Function fscanf does not correctly handle "\t" in
format string
Reported By: [EMAIL PROTECTED]
Status: Open
-Bug Type: Filesystem function related
+Bug Type: Documentation problem
Operating System: Linux RedHat 6.2
PHP Version: 4.0.4pl1
New Comment:
Whitespace characters (be they space, tab, or newline, etc.) in the
format string matche one or more whitespace characters in the input.
So the second \t in your format string is matching the space between
'def' and 'ghi.'
The sample file from the documentation does not include "embedded
whitespace" in the different data columns as yours does.
I'm changing this to a documentation problem because the (f)scanf
documentation is really lacking.
Sean
Previous Comments:
------------------------------------------------------------------------
[2001-07-24 09:45:17] [EMAIL PROTECTED]
When I copy&paste sample from documentation of fscanf function, I
found, that it work incorrectly:
Sample:
while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {
list ($name, $profession, $countrycode) = $userinfo;
}
Sample file:
abc<tab>def ghi jkl<tab> ..... <newline>
Note: <tab> means here a "tabelator" character (\t)
Result:
$name = 'abc'
$profession = 'def';
$contrycode = 'jkl';
I expect:
$name = 'abc'
$profession = 'def ghi jkl';
$contrycode = ' .... ';
What si wrong???
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=12337&edit=1