1.我有这个代码:
$dom->createElement('InvoicesValue', $arrayValue));
我必须更改 $arrayValue:$arrayValue*$arrayTax。不幸的是,当我写这样的文本时,出现错误:
Fatal error: Unsupported operand types
我该如何修复这个问题?
我只粘贴重要的代码:
for($i=0; $i<count($array); $i++){
$arrayValue = $array[$i]['valueInvoice']; //variable imported from MySQL
$arrayTax = ['0.23'];
$fctrl = $dom->createElement('InvoiceCtrl');
$root->appendChild($fctrl);
$fctrl->appendChild($InvoicesValue = $dom->createElement('InvoicesValue', arrayValue*$arrayTax));
}
你有什么想法吗? :)
最佳答案
是的!您正在尝试将 float 存储为数组。值 $arrayTax
应该是一个简单的浮点值,而不是数组
for($i=0; $i<count($array); $i++){
$arrayValue = $array[$i]['valueInvoice']; //variable imported from MySQL
$arrayTax = 0.23; //Change this line to a plain float literal, not an array literal
$fctrl = $dom->createElement('InvoiceCtrl');
$root->appendChild($fctrl);
$fctrl->appendChild($InvoicesValue = $dom->createElement('InvoicesValue', arrayValue*$arrayTax));
}
关于php - 在 DOM createElement 中将两个变量相乘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54019659/