syntaxfscanf(file_pointer, format, mixed)
parametersfile_pointer − a file system pointer resource created using fopen().
format − specify the format. here are the values:
%% - returns a percent%b - binary number%c - the character according to the ascii value%f - floating-point number%f - floating-point number%o - octal number%s - string%d - signed decimal number%e - scientific notation%u - unsigned decimal number%x - hexadecimal number for lowercase letters%x - hexadecimal number for uppercase lettersmixed − specify the assigned values. optional.
returnthe fscanf() function returns the values parsed as an array, if only two parameters were passed.
example<?php $file_pointer = fopen("new.txt", "r"); while ($playerrank = fscanf($handle, "%s\t%d
")) { list ($name, $rank) = $playerrank; echo “$name got rank $rank.”; } fclose($file_pointer);?>
outputamit got rank 2
以上就是php中的fscanf()函数的详细内容。
