我想将整个xml响应数组保存为codeigniter上的.txt或.xml文件中的日志文件?不同的文件名,如文件名,日期和时间?
Array (
[xmlmsg] =>
<Message date="06/05/2018 18:36:39">
<Version>1.0</Version>
<OrderID>12279</OrderID>
<TransactionType>Purchase</TransactionType>
<PAN></PAN>
<PurchaseAmount>200</PurchaseAmount>
<Currency>524</Currency>
<TranDateTime>06/05/2018 18:36:39</TranDateTime>
<ResponseCode></ResponseCode>
<ResponseDescription></ResponseDescription>
<Brand></Brand>
<OrderStatus>CANCELED</OrderStatus>
<ApprovalCode></ApprovalCode>
<AcqFee>0</AcqFee>
<OrderDescription>For booking-200 hour yoga teacher training</OrderDescription>
<ApprovalCodeScr></ApprovalCodeScr>
<PurchaseAmountScr>2,00</PurchaseAmountScr>
<CurrencyScr>524</CurrencyScr>
<OrderStatusScr>CANCELED</OrderStatusScr></Message> )
答案 0 :(得分:0)
在这种情况下,CI文档具有您需要的所有信息:
https://www.codeigniter.com/userguide3/helpers/file_helper.html#write_file
$this->load->helper('file');
if ( ! write_file('./path/to/file.xml', $data['xmlmsg']))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
(其中$data
是你的数组)。