PHP fscanf() Function
Complete PHP Filesystem Reference Manual
Definition and Usage
The fscanf() function parses input from an open file according to a specified format.
Syntax
fscanf(file,format,mixed)
| Parameters | Description |
|---|---|
| file | Required. Specifies the file to check. |
| format | Required. Specifies the format.
Possible format values: |
Additional format values. They must be placed between the % and the letter (for example %.2f):
- + (Prefixes the number with + or - to define its sign. By default, only negative numbers are marked; positive numbers are not)
- ' (Specifies what to use as padding; default is a space. It must be used together with a width specifier. For example: %'x20s (uses "x" as padding))
- - (Left-aligns the variable value)
- [0-9] (Specifies the minimum width of the variable value)
- .[0-9] (Specifies the number of decimal places or the maximum string length)
Note:If multiple of the above format values are used, they must be used in the order shown above and cannot be rearranged.
| | mixed | Optional. |Tips and Notes
Note: Any whitespace in the format string matches any whitespace in the input stream. This means that a tab \t in the format string also matches a single space character in the input stream.
Complete PHP Filesystem Reference Manual