Home >Backend Development >PHP Tutorial >fscanf() function in PHP
The fscanf() function parses input from an open file according to a specified format. It returns the values parsed as an array, if only two parameters were passed.
fscanf(file_pointer, format, mixed)
file_pointer − A file system pointer resource created using fopen().
format − Specify the format. Here are the values:
mixed − Specify the assigned values. Optional.
The fscanf() function returns the values parsed as an array, if only two parameters were passed.
<?php $file_pointer = fopen("new.txt", "r"); while ($playerrank = fscanf($handle, "%s\t%d</p><p>")) { list ($name, $rank) = $playerrank; echo “$name got rank $rank.”; } fclose($file_pointer); ?>
Amit got rank 2
The above is the detailed content of fscanf() function in PHP. For more information, please follow other related articles on the PHP Chinese website!