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

PHP Home Page

Manual Table of Contents
Up to ファイルシステム
Quick Reference
English version of this page
ファイルシステム
* 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 -- フォーマットに基づきファイルからの入力を処理する

説明

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

関数fscanf()sscanf() に 似ていますが、handleが指すファイルから入力 を取得し、指定したフォーマット formatに基 づき解釈を行います。この関数のパラメータが二つだけの場合、処理さ れた値は配列として返されます。他方、オプションのパラメータが指定 された場合、この関数は、代入された値の数を返します。オプション引 数は参照渡しとする必要があります。

例 1. fscanf() の例


$fp = fopen("users.txt","r");
while ($userinfo = fscanf($fp,"%s\t%s\t%s\n")) {
	list($name, $profession, $countrycode) = $userinfo;
	//... 値を用いた処理
}
fclose($fp);
      

例 2. users.txt


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

fread(), fgets(), fgetss(), sscanf(), printf(), 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.