我有一个来自查询的对象数组,如下所示:
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对象更改为布尔数据类型?
感谢,
答案 0 :(得分:1)
使用它时,你必须将它转换为循环中的布尔值。
array_walk($Result, function ($item) {
$item->is_closed = (bool) $item->is_closed;
});