title: How to check boolean field of mysql table and convertion of 0 or 1 value to true/false in php
body: <p>In my query i have 3 tinyint fields which by fetching gives 0/1 value. But after fetching all the data i want to encode that result into JSON format which should get true/false instead of 0/1.
  In my code i have done type conversion, which gives proper result. But i should write for all the tinyint fields which i dont want.
  Is there any method to check tinyint field and for conversion.</p>
  
  <pre><code>PHP CODE: 
  
  
  $result= mysql_query("select incident_main.inc_id as incident_id,
                        ward_master.ward_id as 'ward_id', 
                        GROUP_CONCAT(incident_log.inclog_date) as revisit_dates ,
                        inc_GISlat as lat,
                        inc_GISlon as lon,
              inc_closed as  b_is_closed,
                inc_closeDate as closed_date,
                        incident_statuscd.inc_status_desc as status, 
                        inc_date as 'incident_date', 
                        inc_patientName as 'patient_name',
                        inc_patientAge as 'patient_age',
                        inc_patientGender as 'patient_gender',
                        inc_patientMobile as'patient_mobile' ,
                        inc_patientAddress as 'patient_address',
                        inc_type as type,
                        inc_typeOther as 'type_other',
                        inc_diagnosis as diagnosis,
                        inc_recurrence as recurrence,
                inc_hospitalized as b_hospitalized, 
                        inc_treatment as treatment ,
                        inc_treatmentOther as 'treatment_other' 
                    from 
                        incident_main,
                        incident_statuscd ,
                        ward_master,
                        incident_log 
                    where 
                        inc_status=incident_statuscd.inc_status_id 
                       and 
                        incident_main.inc_patientWard=ward_master.ward_id 
                       and incident_log.inc_id=incident_main.inc_id ") 
                        or die(mysql_error);
  while($res = mysql_fetch_assoc($result)) {
   foreach($res as $key =&gt; $value) {
       if(substr( $key, 0, 2 ) === "b_") {
           // assign new value
           $res[substr($key,2,strlen($key))] = !!$value;
           //clean up old value
           unset($res[$key]);
           };
  
    }
    $data=array_filter($res);
  
  echo json_encode($data, true);
  </code></pre>
  
  <p>Please help!! 
  Thanks in advance.</p>