Log in

View Full Version : Resolved file_put_contents line breaks \n



ggalan
09-14-2011, 04:16 PM
i am trying to put line breaks in a jSon txt file with line breaks but it doesnt seem to be responding. any suggestions please, thank you


$i = 0;
$entryText = '{"comments":[';
foreach($entryList['comments'] as $commentItem) {
$num = $newStack[$i];

$entryText .= "\n" . '{"index":'.$nTotal.',"text":"'.$arrTxt[$num].'","img":"'.$arrImg[$num].'"}';

$i++;
$nTotal--;
if ($i < count($newStack)) {$entryText .= ','; }
}
$entryText .= ']}';

file_put_contents('data/cache.txt', $entryText);

ggalan
09-14-2011, 04:33 PM
sometimes i overlook the obvious, i had it encode a .txt instead of a .json file