ExpertRefresh

Streams / File parse  

1) Parse input from a file






fscanf() <?php // Parses input from a file according to a format // Similar to sscanf(), but it takes its input from a file associated with handle /* -- example.txt John Smith 24 Mary Jones 35 Tom Ferguson 45 */ $fp = fopen("example.txt", "r"); while($row = fscanf($fp, "%st%st%dn")) { list($surname, $name, $age) = $row; echo "{$name} {$age}"; break; // Outputs: Smith 24 } fclose($fp);


References