★ wanayoo — archive 1999 http://www.php.net/manual/function.fscanf.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Filesystem
Quick Reference
Japanese version of this page
Filesystem
* basename
* chgrp
* chmod
* chown
* clearstatcache
* copy
* delete
* dirname
* diskfreespace
* fclose
* feof
* fgetc
* fgetcsv
* fgets
* fgetss
* file
* file_exists
* fileatime
* filectime
* filegroup
* fileinode
* filemtime
* fileowner
* fileperms
* filesize
* filetype
* flock
* fopen
* fpassthru
* fputs
* fread
* fscanf
* fseek
* fstat
* ftell
* ftruncate
* fwrite
* set_file_buffer
* is_dir
* is_executable
* is_file
* is_link
* is_readable
* is_writeable
* link
* linkinfo
* mkdir
* pclose
* popen
* readfile
* readlink
* rename
* rewind
* rmdir
* stat
* lstat
* realpath
* symlink
* tempnam
* touch
* umask
* unlink
Manual: fscanf
View the source code for this pageSearch the site



Previous page
 fread
 Updated
Sat, 12 Aug 2000
fseek 
Next page


fscanf

(PHP4 >= 4.0.1)

fscanf -- Parses input from a file according to a format

Description

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

The function fscanf() is similar to sscanf(), but it takes its input from a file associated with handle and interprets the input according to the specified format. If only two parameters were passed to this function, the values parsed will be returned as an array. Otherwise, if optional parameters are passed, the function will return the number of assigned values. The optional parameters must be passed by reference.

Example 1. Fscanf() Example


$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);
	 

Example 2. users.txt


javier	argonaut	pe
hiroshi	sculptor	jp
robert	slacker	us
luigi	florist	it
	 

See also fread(), fgets(), fgetss(), sscanf(), printf(), and sprintf().


 About Notes


Previous page
 fread
 Updated
Sat, 12 Aug 2000
fseek 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.