0

我有一个来自查询的对象数组,如下所示:

大批
(
    [0] => 标准类对象
        (
            [行号] => 1
            [cash_id] => 30938
            [关闭_id] =>
            [已关闭] => 0
            [现金日期] => 2018-04-03
            [store_id] => 13
            [商店代码] => 504
            [store_account] => ST0013
            [store_vendor] => ES0013
            [store_dwds] => 01R-0101A006S0013
            [store_name] => KARTIKA 钱德拉
            [area_id] => 11
            [area_code] => A11
            [area_name] => 区域 11
            [region_id] => 1
            [区域代码] => R01
            [region_name] => 区域 1
            [关闭日期] =>
            [关闭类型] =>
            [关闭类型描述] =>
            [现金金额] => 6000000.0000
            [收盘金额] =>
            [更新时间] =>
            [update_by_username] =>
            [update_by_first_name] =>
            [update_by_last_name] =>
            [update_by_email] =>
        )
   [1] => 标准类对象
        (
            [行号] => 1
            [cash_id] => 30938
            [关闭_id] =>
            [已关闭] => 0
            [现金日期] => 2018-04-03
            [store_id] => 13
            [商店代码] => 504
            [store_account] => ST0013
            [store_vendor] => ES0013
            [store_dwds] => 01R-0101A006S0013
            [store_name] => KARTIKA 钱德拉
            [area_id] => 11
            [area_code] => A11
            [area_name] => 区域 11
            [region_id] => 1
            [区域代码] => R01
            [region_name] => 区域 1
            [关闭日期] =>
            [关闭类型] =>
            [关闭类型描述] =>
            [现金金额] => 6000000.0000
            [收盘金额] =>
            [更新时间] =>
            [update_by_username] =>
            [update_by_first_name] =>
            [update_by_last_name] =>
            [update_by_email] =>
        )
)


如何将 is_closed 对象更改为布尔数据类型?

谢谢,

4

1 回答 1

1

使用时,您必须将其转换为循环中的布尔值。

array_walk($Result, function ($item) {
    $item->is_closed = (bool) $item->is_closed;    
});
于 2018-04-03T13:47:28.493 回答