File system function Library: fscanf

Source: Internet
Author: User
Keywords fscanf php Chinese function manual file system function library
Tags aliyun file file system function library function function library html http php

fscanf

(PHP4 >= 4.0.1)

FSCANF---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Profiling files by format

Syntax: mixed fscanf (int handle, string format [, String var1 ...])

Description:

This function fscanf () is similar to sscanf (), but it takes its input from a file, and interprets its input according to the format specified. If only two parameters are passed to this function, the returned value will be an array, otherwise, if there is a pass of non-essential parameters, this function will return the number of allocation (assigned) values, and non-essential parameters must be passed in accordance with the relationship.

Example:

<?php

$fp = fopen ("Users.txt", "R");

while ($userinfo = fscanf ($fp, "%s\t%s\t%s\n")) {

List ($name, $profession, $countrycode) = $userinfo;

... do something with the values

}

Fclose ($FP);

?>

Users.txt:

Javier Argonaut PE
Hiroshi Sculptor JP
Robert Slacker US
Luigi Florist It

Reference: Fread () fgets () fgetss () sscanf () printf () sprintf ()

Related Article

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.