How to use Filesystem fscanf in PHP
In this article I am going to explain about fscanf function in PHP.
PHP fscanf() Function
The filesystem fscanf function parses input from a file according to a format.
Syntax of fscanf function
fscanf(file, format, mixed) |
Parameters in fscanf function
It have three parameter:
Parameter |
Description |
file |
It specifies the open file to check. |
format |
It specifies the format. |
mixed |
It is optional parameter |
Example of filesystem fscanf function
<html>
<body>
<?php
$handle = fopen("C:\wamp\www\Dinesh\Mcn.txt", "r");
while ($userinfo = fscanf($handle, "%s\t%s\t%s\n"))
{
list ($name, $profession, $countrycode) = $userinfo;
echo "name=". $name."</br>";
echo "profession=".$profession."</br>";
echo "countrycode=".$countrycode;
}
fclose($handle);
?>
</body>
</html>
|
Output:
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here