是否有任何技巧可以将返回的tinyint记录类型转换为codeigniter中的boolean?
我有这个记录:
[{
"id": "1",
"body": "Go to store",
"completed": "1"
}, {
"id": "2",
"body": "Learn Angular",
"completed": "0"
}]
我想将已完成的属性转换为布尔值,因此结果将如下所示:
[{
"id": "1",
"body": "Go to store",
"completed": true
}, {
"id": "2",
"body": "Learn Angular",
"completed": false
}]
怎么做?
之前谢谢答案 0 :(得分:0)
你应该在json之外转换它,只需尝试:
$completed = ($completed === 1)
答案 1 :(得分:0)
试试这个:
foreach($yourjsondata as $j)
$j['completed'] = ($j['completed'] === "1");