Placing header in CSV file

0

I have a log generation routine on a customer's page. However, I always have to add a header field in the first row. Here is the function code:

public function generateLogPMWeb($action){
    session_start('usuario');
    $logPMWeb  = $_SESSION['usuario']['id'] . ";" . $_SESSION['usuario']['id'] . "_" . $_POST['idHotel'] . "_" . date('YmdHis') . ";" . $_SESSION['usuario']['nome'] . ";" . $_SESSION['usuario']['sobrenome'] . ";" . $_SESSION['usuario']['email'] . ";" . "IC"
            . ";" . $_SESSION['usuario']['id'] . "_" . $_POST['idHotel'] . "_" . date('YmdHis') . ";" . $_POST['idHotel'] . ";" . date('Y-m-d H:i:s') . ";" . $_SESSION['buscaReserva']['dataInicio'] . ";" . $_SESSION['buscaReserva']['dataFim']
            . ";" . "Acao: " .  preg_replace('/^\s+|\n|\r|\s+$/m', '', $action) . ";\n";
    file_put_contents(Config::retorna("document_root", "root").'/logs/logPMWeb_'.date("Ymd").'.csv', $logPMWeb, FILE_APPEND);
}

I have already looked at other sites for the use of the fputcsv function, but I do not know how it works. Is it better to do it?

    
asked by anonymous 24.03.2015 / 17:57

0 answers