Fscanf
("= 4.0.1, PHP 5" in PHP 4)
Fscanf-parse the format of the input file according
Description
Hybrid fscanf (resource $ processing, string $ format [, Hybrid & $...])
The function fscanf () is similar to sscanf (), but the input required from archive and processing and interpretation is based on the specified format, which is described in the document sprintf ().
Any space format string matches any blank input stream. This means that even if a tag T matches a single space character input stream in the format string.
Each phone fscanf () reads a row from the archive.
Parameters
Handle
A file system pointer resource is usually created using the fopen () function.
Format
Specifies the sprintf () file described in the format.
...
Optional value.
Return value
If there are only two parameters, value parsing returns an array. Otherwise, if an optional parameter is passed, the function returns a specified number of values. Optional parameters must be passed through reference.
Modify
Version description
4.3.0 at the time prior to this, the maximum number of characters read from the file is 512 (or the first nitrogen, the two ranked first ). But now, any long row reads and scans.
Instance
For example, #1 fscanf ()
<? Php
$ Handle = fopen ("users.txt", "r ");
While ($ userinfo = fscanf ($ handle, "% st % sn ")){
List ($ name, $ declaration, $ countrycode) = $ userinfo;
//... Do something with the values
}
Fclose ($ handle );
?>