Mega Code Archive

 
Categories / Php / File Directory
 

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); ?>