I have a result from a query which I am writing to a file. I want the file to list the rows vertically instead of horizontally. I have the following code:
$fh = fopen($file, 'w');
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$array[] = implode('|', $row);
}
foreach($array as $arr) {
fputs($fh, $arr) . ',';
}
fclose($fh);
Ive tried replacing the comma with \r\n but the file still contains the horizontal representation of the data. BTW the ',' may not be in the correct place in the code.
Put escape characters inside double quotes.