douyinyi7766 2017-04-26 12:48
浏览 42

PHP SimpleXMLElement对象 - 检查子行项目值

I'm working with a SimpleXMLElement Object and retrieving amounts for invoices, some of which contain several line items each with a zero dollar value. I now need to skip any invoices where each of the line items has a zero dollar value. Here's an example:

    [11] => SimpleXMLElement Object
(
    [Contact] => SimpleXMLElement Object
        (
            [ContactID] => gzd123456
            [Name] => Acme Inc.
        )

    [Date] => 2017-04-13T00:00:00
    [DueDate] => 2017-04-13T00:00:00
    [Status] => PAID
    [LineAmountTypes] => Inclusive
    [LineItems] => SimpleXMLElement Object
        (
            [LineItem] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [Description] => Stock on hand
                            [UnitAmount] => 0.00
                            [TaxAmount] => 0.00
                            [LineAmount] => 0.00
                            [Quantity] => 1.0000
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [Description] => Cost of goods sold
                            [UnitAmount] => 0.00
                            [TaxAmount] => 0.00
                            [LineAmount] => 0.00
                            [Quantity] => 1.0000
                        )

                )

        )

    [UpdatedDateUTC] => 2017-04-12T22:55:02.657
    [CurrencyCode] => AUD
    [Type] => ACCPAY
    [HasAttachments] => false
)

I'm looping through each invoice like this:

foreach ($invoices->Invoices->Invoice as $invoice) {

then looping through each invoice line item like this:

foreach ($invoiceLineItems->LineItem as $invoiceLineItem) {
    $LineAmount = $invoiceLineItem-> LineAmount;
}

which is working fine, but I would like to short circuit the foreach ($invoiceLineItems->LineItem as $invoiceLineItem) { if possible where all LinteItem>LineAmount values are '0.00'. Is it possible to query all the LineItems at once to see if they are all equal to '0.00'?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度