Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

splfileobject.fscanf(3) [php man page]

SPLFILEOBJECT.FSCANF(3) 						 1						   SPLFILEOBJECT.FSCANF(3)

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

SYNOPSIS
public mixed SplFileObject::fscanf (string $format, [mixed &$...]) DESCRIPTION
Reads a line from the file and interprets it according to the specified $format, which is described in the documentation for sprintf(3). Any whitespace in the $format string matches any whitespace in the line from the file. This means that even a tab in the format string can match a single space character in the input stream. PARAMETERS
o $format - The specified format as described in the sprintf(3) documentation. o $... - The optional assigned values. RETURN VALUES
If only one parameter is passed to this method, 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. EXAMPLES
Example #1 SplFileObject::fscanf example <?php $file = new SplFileObject("misc.txt"); while ($userinfo = $file->fscanf("%s %s %s")) { list ($name, $profession, $countrycode) = $userinfo; // Do something with $name $profession $countrycode } ?> Contents of users.txt javier argonaut pe hiroshi sculptor jp robert slacker us luigi florist it SEE ALSO
fscanf(3). PHP Documentation Group SPLFILEOBJECT.FSCANF(3)

Check Out this Related Man Page

SPLFILEOBJECT(3)							 1							  SPLFILEOBJECT(3)

The SplFileObject class

INTRODUCTION
The SplFileObject class offers an object oriented interface for a file. CLASS SYNOPSIS
SplFileObject SplFileObjectextends SplFileInfoRecursiveIteratorSeekableIterator Constants o const integer$SplFileObject::DROP_NEW_LINE1 o const integer$SplFileObject::READ_AHEAD2 o const integer$SplFileObject::SKIP_EMPTY4 o const integer$SplFileObject::READ_CSV8 Methods o public SplFileObject::__construct (string $filename, [string $open_mode = "r"], [bool $use_include_path = false], [resource $con- text]) o public string|array SplFileObject::current (void ) o public bool SplFileObject::eof (void ) o public bool SplFileObject::fflush (void ) o public string SplFileObject::fgetc (void ) o public array SplFileObject::fgetcsv ([string $delimiter = ","], [string $enclosure = " o public string SplFileObject::fgets (void ) o public string SplFileObject::fgetss ([string $allowable_tags]) o public bool SplFileObject::flock (int $operation, [int &$wouldblock]) o public int SplFileObject::fpassthru (void ) o public int SplFileObject::fputcsv (array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape = " o public string SplFileObject::fread (int $length) o public mixed SplFileObject::fscanf (string $format, [mixed &$...]) o public int SplFileObject::fseek (int $offset, [int $whence = SEEK_SET]) o public array SplFileObject::fstat (void ) o public int SplFileObject::ftell (void ) o public bool SplFileObject::ftruncate (int $size) o public int SplFileObject::fwrite (string $str, [int $length]) o public void SplFileObject::getChildren (void ) o public array SplFileObject::getCsvControl (void ) o public int SplFileObject::getFlags (void ) o public int SplFileObject::getMaxLineLen (void ) o public bool SplFileObject::hasChildren (void ) o public int SplFileObject::key (void ) o public void SplFileObject::next (void ) o public void SplFileObject::rewind (void ) o public void SplFileObject::seek (int $line_pos) o public void SplFileObject::setCsvControl ([string $delimiter = ","], [string $enclosure = " o public void SplFileObject::setFlags (int $flags) o public void SplFileObject::setMaxLineLen (int $max_len) o public void SplFileObject::__toString (void ) o public bool SplFileObject::valid (void ) Inherited methods o public SplFileInfo::__construct (string $file_name) o public int SplFileInfo::getATime (void ) o public string SplFileInfo::getBasename ([string $suffix]) o public int SplFileInfo::getCTime (void ) o public string SplFileInfo::getExtension (void ) o public SplFileInfo SplFileInfo::getFileInfo ([string $class_name]) o public string SplFileInfo::getFilename (void ) o public int SplFileInfo::getGroup (void ) o public int SplFileInfo::getInode (void ) o public string SplFileInfo::getLinkTarget (void ) o public int SplFileInfo::getMTime (void ) o public int SplFileInfo::getOwner (void ) o public string SplFileInfo::getPath (void ) o public SplFileInfo SplFileInfo::getPathInfo ([string $class_name]) o public string SplFileInfo::getPathname (void ) o public int SplFileInfo::getPerms (void ) o public string SplFileInfo::getRealPath (void ) o public int SplFileInfo::getSize (void ) o public string SplFileInfo::getType (void ) o public bool SplFileInfo::isDir (void ) o public bool SplFileInfo::isExecutable (void ) o public bool SplFileInfo::isFile (void ) o public bool SplFileInfo::isLink (void ) o public bool SplFileInfo::isReadable (void ) o public bool SplFileInfo::isWritable (void ) o public SplFileObject SplFileInfo::openFile NULL ([string $open_mode = "r"], [bool $use_include_path = false], [resource $context]) o public void SplFileInfo::setFileClass ([string $class_name = "SplFileObject"]) o public void SplFileInfo::setInfoClass ([string $class_name = "SplFileInfo"]) o public void SplFileInfo::__toString (void ) PREDEFINED CONSTANTS
o SplFileObject::DROP_NEW_LINE -Drop newlines at the end of a line. o SplFileObject::READ_AHEAD -Read on rewind/next. o SplFileObject::SKIP_EMPTY -Skips empty lines in the file. This requires the READ_AHEAD flag be enabled, to work as expected. o SplFileObject::READ_CSV -Read lines as CSV rows. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.9 | | | | | | | | | | SplFileObject::SKIP_EMPTY value changed to 4. | | | Previously, value was 6. | | | | +--------+---------------------------------------------------+ PHP Documentation Group SPLFILEOBJECT(3)
Man Page