I am creating a text file with the following code:
$textcreate = "**************************************
" . PHP_EOL;
$textcreate .= "Item Amt Qty Total" . "
" . PHP_EOL;
if (isset($print_table_for_txt_file["ordereditems"])) {
foreach ($print_table_for_txt_file["ordereditems"] as $key => $value) {
$textcreate .= $value['item_name'] . " " . number_format((float) $value['withoutTax_itemPrice'], 2, '.', '') . "
" . PHP_EOL;
}
}
$textcreate .= "**************************************
" . PHP_EOL;
$textcreate .= "Amount Payable: " . round($print_table_for_txt_file['api']['0']['GrandTotal']) . ".00
" . PHP_EOL;
$textcreate .= "**************************************
" . PHP_EOL;
$myfile = fopen("example.txt", "w") or die("Unable to open file!");
fwrite($myfile, $textcreate);
The output of the file is :
************************************** Item Amt Qty Total pen 10.00 1 10.00 ************************************** Amount Payable: 10.00 **************************************
But I want the output to be :
**************************************
Item Amt Qty Total
pen 10.00 1 10.00
**************************************
Amount Payable: 10.00
**************************************
What should I do