$fileName");//printReportHeading(); $lineIn = fgets($fp); // primer input while ( !feof($fp) ) { $groupIn = substr($lineIn, 30, 11); // extract control field(group) $groupControl = $groupIn; // initialize new group $groupOut = $groupIn; while ($groupIn == $groupControl) { // process one group $id = substr($lineIn, 0, 5); // extract other fields $name = substr($lineIn, 5, 25); $price = substr($lineIn,41,5); $groupTotal += $price; $price = number_format($price,2); print("$groupOut$id$name". "$price"); $lineIn = fgets($fp); // get next record(line) $groupIn = substr($lineIn, 30, 11); // extract control field } // end inner loop $groupTotal = number_format($groupTotal,2); print("group total:". "$groupTotal"); $groupControl = $groupIn; // initialize new group $groupOut = $groupIn; $groupTotal = 0.00; } // end outer loop fclose($fp); ?>