<?php require_once ('header.php');
if (isset($_POST["Import"]))
{
    try
    {
        $csv= file_get_contents($_FILES["file"]["tmp_name"]);
        $array = array_map("str_getcsv", explode("\n", $csv));
        $json = json_encode($array);
        
        $header_data=$array[0];
        
        foreach($header_data as $d){
                $data.$d=array();
                $data.$d[]=$d;
                
                print_r($data.$d[0]); 
        }
        
        echo $header_data[0];
        
        $f=0;
        
       echo '<div class="box-body table-responsive"><table style="width:100%;font-size:8px;" class="table table-bordered table-striped"><tr>'; 
        foreach($header_data as $d){
            echo '<th>'.$f.'.'.$d.'</th>';
            $f++;
        }
        echo '</tr>';
        
        
         for($b=1;$b<count($array);$b++){
            $f=1;
            echo '<tr>';
            $body_data=$array[$b];
            foreach($body_data as $d){
                echo '<td>'.$d.'</td>';
                $f++;
                /*$ff=$header_data[$f-1];
                $data.$ff[]=array_search("CONSIGNEE_NAME",$body_data);*/
            }
            echo '</tr>';
        }
        echo '</table></div>'; 
        
        
        
        
        
        
        echo '<br><br>';
            echo 'Row 1 Orgin City:'.array_search("CONSIGNEE_NAME",$header_data);
        echo '<br><br>';
        
       
        
    }catch(Exception $e){
        echo $e;
    }    
} ?>

<style>
    td,th{
        border:1px solid gray;
    }
</style>
<?php require_once ('footer.php'); ?>