Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $firstName = "";
- $lastName = "";
- $age = 0;
- $yearsUntilOneHundred = 0;
- $recordCount = 0;
- $msg = "";
- //Opens the file or kills the app
- $fin = fopen("names.txt","r") or die("cannot open names.txt");
- fprintf($fout,"\n SALES REPORT\n");
- fprintf($fout,"\n First Last Years till 100\n");
- $fout = fopen("report.txt","w") or die("cannot open names.txt");
- //Read the first record
- fscanf($fin, "%s%s%d,$firstName, $lastName, $age");
- while( !feof($fin))
- {
- //processing
- if ($age >= 90)
- {
- $msg="Older than dirt";
- }
- else
- {
- $msg = "Just a kid!";
- }
- $recordCount = $recordCount + 1;
- $yearsUntilOneHundred = 100-$age;
- fprintf($fout,"\n%-10s%-10s%12d %-17s",
- $firstName, $lastName, $yearsUntilOneHundred, $msg);
- //Read next record
- fscanf($fin,"%s%s%d", $firstName, $lastName, $age);
- }
- fprintf($fout,"\nRecord Count is %d", $recordCount);
- fclose ($fin);
- fclose ($fout);
- //fscanf(STDIN, "%s", $buster);
- ?>
Add Comment
Please, Sign In to add comment