making csv file, with multiple values, but this value is array for csv. continue reading below....

$this->envoirment = str_replace("\r\n", "\n", $this->envoirment);
$this->envoirment = str_replace('"', '""', $this->envoirment);
$message .= "\"\"$this->envoirment\"\" \n";		

i have array which i serilzed it to string, now this string content comma's, new lines and quotes.

i tryed almost every method to bypass the comma or new line for csv to pickup as single field

    Have you considered using [man]fputcsv[/man]?

    EDIT: Actually, ignore that. It won't help. You just have to escape all the special characters in your serialized string.

      so how to escape comma and new lines, without distroying the serilized data.

        i just wanted to say thank you and if any othere person has same problem, following is solution for it:

        // before
        $header = '"Date Time", "Error", "Message", "SQL", "Line", "File", "IP", "Envoirment"'."\n";
        
        //after
        $header = '"Date Time","Error","Message","SQL","Line","File","IP","Envoirment"'."\n";
        

        dont put space after comma, if you put space then it will not take " double quotes as enclosed key.

        glad to help and get help, thank you every one.

          Write a Reply...