Mysql / PHP / json_encode boolean string conversion
Well, you are selecting from the database as string. So that's what gets encoded. Use SQL true
/false
boolean values, which in PHP become 0
/1
, and cast them to PHP booleans before JSON encoding them:
$data['id'] = (bool)$data['id']; // 0/1 -> PHP false/true
echo json_encode($data); // {'id':true}