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 ()