Home > Mobile >  Skip first row when overwriting the CSV file in PHP
Skip first row when overwriting the CSV file in PHP

Time:09-17

I need help with skipping the first row when i overwrite the file. Because i get the date over the first row where i want to put a headers. Like date name etc . I tried with continue; , but its not working .

$result =[];
foreach($sumArray as $key => $totalItems)   {
    $result[$totalItems][ ]= $sumArray1[$key];
    $timeNeeded = implode(" ", $result[$totalItems]);
    list($id1, $name1) = explode('_', $key);
    $rows = 0;

    $procenti = round(($perMin*$totalItems)/($timeNeeded/$precentEff),2);
    $procentiCon = $procenti . " %";
    $pickingEffRes = [$name1 , $totalItems, $procentiCon];
    
    if($rows == 1) continue;
    
    fputcsv($out, $pickingEffRes);
    $rows  ;
}  

CodePudding user response:

$result =[];
$rows = 0;

foreach($sumArray as $key => $totalItems)   {
    $result[$totalItems][ ]= $sumArray1[$key];
    $timeNeeded = implode(" ", $result[$totalItems]);
    list($id1, $name1) = explode('_', $key);

    $procenti = round(($perMin*$totalItems)/($timeNeeded/$precentEff),2);
    $procentiCon = $procenti . " %";
    $pickingEffRes = [$name1 , $totalItems, $procentiCon];
    
    if($rows == 1) continue;
    
    fputcsv($out, $pickingEffRes);
    $rows  ;
}  

  • Related