PHP fscanf function _php Tutorial

Source: Internet
Author: User
PHP fscanf functions

fscanf
(php 4 "= 4.0.1, PHP 5)

FSCANF-Parse the format of the input file according to

Describe
Mixed FSCANF (Resource $ processing, string $ format [, mixed &$ ...])
The function fscanf () is similar to sscanf (), but requires input from the archive with the input of processing and interpretation according to the specified format, which is described in the literature as sprintf ().

Any whitespace in the format string matches any blank input stream. This means that even if a label T in the format string can match a single space character in the input stream.

Each phone fscanf () reads a row from the archive.

Parameters

Handle
A file system pointer to a resource, typically created using the fopen () function.

Format
A file that specifies the sprintf () described in the format.

...
The specified value that is optional.


return value
If there are only two parameters, value resolution returns an array through this function. Otherwise, if an optional argument is passed, the function returns the specified number of values. Optional parameters must be passed by reference.

Modify

Release Notes
4.3.0 before this time, the maximum number of characters to read the file is 512 (or the first nitrogen, both ranked first). But now, any long rows are read and scanned.


Instance

Example # 1 fscanf () for example

$handle = fopen ("Users.txt", "R");
while ($userinfo = fscanf ($handle, "%ST%ST%SN")) {
List ($name, $profession, $countrycode) = $userinfo;
... do something with the values
}
Fclose ($handle);
?>


http://www.bkjia.com/PHPjc/445470.html www.bkjia.com true http://www.bkjia.com/PHPjc/445470.html techarticle php fscanf function fscanf (php 4 = 4.0.1, PHP 5) fscanf-Parse the format of the input file according to the description Mix fscanf (Resource $ processing, string $ format [, mixed $ ...]) ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.