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);
$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);