Query: fscanf
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
FSCANF(3) 1 FSCANF(3) fscanf - Parses input from a file according to a formatSYNOPSISmixed fscanf (resource $handle, string $format, [mixed &$...])DESCRIPTIONThe function fscanf(3) is similar to sscanf(3), but it takes its input from a file associated with $handle and interprets the input 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 input stream. This means that even a tab in the format string can match a single space character in the input stream. Each call to fscanf(3) reads one line from the file.PARAMETERSo $handle -A file system pointer resource that is typically created using fopen(3). o $format - The specified format as described in the sprintf(3) documentation. o $... - The optional assigned values.RETURN VALUESIf 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.EXAMPLESExample #1 fscanf(3) Example <?php $handle = fopen("users.txt", "r"); while ($userinfo = fscanf($handle, "%s %s %s ")) { list ($name, $profession, $countrycode) = $userinfo; //... do something with the values } fclose($handle); ?> Example #2 Contents of users.txt javier argonaut pe hiroshi sculptor jp robert slacker us luigi florist itSEE ALSOfread(3), fgets(3), fgetss(3), sscanf(3), printf(3), sprintf(3). PHP Documentation Group FSCANF(3)
Related Man Pages |
---|
sscanf(3s) - bsd |
scanf(3) - minix |
stdio(3) - minix |
fscanf(3int) - ultrix |
scanf(3int) - ultrix |
Similar Topics in the Unix Linux Community |
---|
fscanf() |
C, using fscanf |
fopen() - don't know what I'm doing wrong |
fscanf: read words from file |
Compare two files based on values of fields. |