Reading Formatted Text Using fscanf() : fscanf « File Directory « PHP






Reading Formatted Text Using fscanf()

 
<?php
     $fr = @fopen('data.txt', 'r');
     if(!$fr) {
          echo "Error! Couldn't open the file.<BR>";
          exit;
     }

     while(!feof($fr)) {
          fscanf($fr, "%u-%u-%u %s %s", &$month, &$day,
                                        &$year, &$first, &$last);
          echo "First Name: $first<BR>";
          echo "Last Name: $last<BR>";
          echo "Birthday: $month/$day/$year<BR>";
     }
     fclose($fr);
?>
  
  








Related examples in the same category

1.Acceptable Format Values for fscanf()
2.fscanf.php