簡體   English   中英

如何從result_object Codeigniter轉換數據類型

[英]how to convert data type from result_object codeigniter

我有來自查詢的對象數組,如下所示:

Array
(
    [0] => stdClass Object
        (
            [row_number] => 1
            [cash_id] => 30938
            [closing_id] => 
            [is_closed] => 0
            [cash_date] => 2018-04-03
            [store_id] => 13
            [store_code] => 504
            [store_account] => ST0013
            [store_vendor] => ES0013
            [store_dwds] => 01R-0101A006S0013
            [store_name] => KARTIKA  CHANDRA
            [area_id] => 11
            [area_code] => A11
            [area_name] => Area 11
            [region_id] => 1
            [region_code] => R01
            [region_name] => Region 1
            [closing_date] => 
            [closing_type] => 
            [closing_type_desc] => 
            [cash_amount] => 6000000.0000
            [closing_amount] => 
            [update_time] => 
            [update_by_username] => 
            [update_by_first_name] => 
            [update_by_last_name] => 
            [update_by_email] => 
        )
   [1] => stdClass Object
        (
            [row_number] => 1
            [cash_id] => 30938
            [closing_id] => 
            [is_closed] => 0
            [cash_date] => 2018-04-03
            [store_id] => 13
            [store_code] => 504
            [store_account] => ST0013
            [store_vendor] => ES0013
            [store_dwds] => 01R-0101A006S0013
            [store_name] => KARTIKA  CHANDRA
            [area_id] => 11
            [area_code] => A11
            [area_name] => Area 11
            [region_id] => 1
            [region_code] => R01
            [region_name] => Region 1
            [closing_date] => 
            [closing_type] => 
            [closing_type_desc] => 
            [cash_amount] => 6000000.0000
            [closing_amount] => 
            [update_time] => 
            [update_by_username] => 
            [update_by_first_name] => 
            [update_by_last_name] => 
            [update_by_email] => 
        )
)

如何將is_closed對象更改為布爾數據類型?

謝謝,

使用它時,必須將其轉換為循環中的布爾值。

array_walk($Result, function ($item) {
    $item->is_closed = (bool) $item->is_closed;    
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM