Question: File: fixit5.php Purpose: What's wrong here? This program is supposed to open a file for reading, read three first names. last names, and wage amounts
File: fixit5.php Purpose: What's wrong here? This program is supposed to open a file for reading, read three first names. last names, and wage amounts from the file, close the file, calculate the total and average, and display the employees' names and wages, total and average. But when the program runs, the output is very strange!
Hint: Look at the wages2.txt file to see how the data is stored Now look at how this data is being parsed - the problem has to do with the explode() functions. -->
WAGE REPORT
$employee1 = fgets($wageFile); // reads data for the 1st employee from the file $employee2 = fgets($wageFile); // reads data for the 2nd employee from the file $employee3 = fgets($wageFile); // reads data for the 3rd employee from the file fclose($wageFile);
list($firstName1, $lastName1, $wage1) = explode(":", $employee1); list($firstName2, $lastName2, $wage2) = explode(":", $employee2); list($firstName3, $lastName3, $wage3) = explode(":", $employee3);
$totalWages = $wage1 + $wage2 + $wage3; $avgWage = $totalWages/3;
print("
$lastName1, $firstName1: $$wage1 "); print("$lastName2, $firstName2: $$wage2 "); print("$lastName3, $firstName3: $$wage3
"); print("TOTAL WAGES PAID: $$totalWages
"); print("AVERAGE WAGE: $$avgWage
"); ?>Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
