Welcome Guest, Not a member yet? Register   Sign In
How do I create line breaks when passing a string into codeigniter's download helper
#1

[eluser]Unknown[/eluser]
How do I create line breaks when passing a string into codeigniter's download helper. I have tried the code below which succesfully downloads the file and the string but it just outputs directly the \r\n rather than converting them into new lines. Any help would be greatly appreciated:

Code:
$reportOutput = '';

foreach($data['displayPostingRecords'] as $result)
{
$reportOutput .=  rawurldecode($result['wpPostlink']).' \r\n ';
}

//download the file..
$fileName = 'report-articleBatchID-'.$articleBatchID.'.txt';
$this->load->helper('download');
force_download($fileName, $reportOutput);
#2

[eluser]Unknown[/eluser]
Just found the answer so posting solution for anyone else who encounters it ...

the '\r\n' needs to be on double quotes...so corrected code is

Code:
$reportOutput = '';

foreach($data['displayPostingRecords'] as $result)
{
$reportOutput .=  rawurldecode($result['wpPostlink'])." \r\n ";
}

//download the file..
$fileName = 'report-articleBatchID-'.$articleBatchID.'.txt';
$this->load->helper('download');
force_download($fileName, $reportOutput);




Theme © iAndrew 2016 - Forum software by © MyBB