1

I am working on project where I am uploading two excel files and able to get the files data in 2d associative arrays.

  1. I want to calculate the total of 2 rows if it exists only on array1 and not exists on array2.
  2. I want to highlight the duplicates from these results and wants to show data
  3. also currently its displaying the matching tracking number rows from two files, but I want to show the rows whose tracking number exist in array1 but not on array 2.

for now $fees and $service_charge is adding up for many times, I want to calculate the total against existing rows like if there are two rows with $fees then variable fees should return total of two rows amount.



`
for($p=10; $p<=count($array2); $p++){
            for($u=1; $u<=count($array1); $u++){
                     if($array1[$u]['Charge'] == "Fees") 
                     {
                         $ufee = $array1[$u]['Billed Charge'];
                         $fees_amount =  floatval($fee);
                         $fees += $fees_amount;
                     }
                     else if($array1[$u]['Charge'] == "Service Charge")
                     {
                         $sc = $array1[$u]['Billed Charge'];
                         $sc_amount =  floatval($sc);
                         $service_charge += $sc_amount;
                     }
                    if( ($array1[$u]['Tracking Number'] == $array2[$p]['Tracking #']) ){
                            $reslutArr[$newIndex] = array(
                                "tracking_number" =>  $array1[$u]['Tracking Number'], 
                                "service_type" => $array1[$u]['Charge'], 
                                "amount" =>   $array1[$u]['Billed Charge'], 
                                "fees " =>  $fees , 
                                "service_charge " =>  $service_charge ,
                                "total_matching_rows" =>  $matching,
                            );
                        $newIndex++;
                        $matching++;
                    }   
            }
        } 


`





Alex
  • 23
  • 2

0 Answers0