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
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.