Reputation: 59
I am trying to write in a text file and after each line is written the next line will be in the new line. But when i check my txt file, it is showing every entry in the same line. Although \t is working, there is a tab in between each field. Here is my code
foreachloop{
$fp=fopen("order.txt", "a");
fwrite($fp,$item_name."\t".$item_price."\t" .$each_item['quantity']."\t" .$total_price."\t" .$fname."\n");
$i++;
}//end of for each loop
fclose($fp);
print "added";
Upvotes: 1
Views: 50
Reputation: 239260
Not all operating systems use "\n"
as the line delimiter. Use PHP_EOL
to insert the end-of-line character(s) appropriate for your operating system.
fwrite($fp, $item_name . "..." . $fname . PHP_EOL);
Upvotes: 4