Q:

Replace column namne with custom name with json_encode

I'm bringing json_encode data from the db.
foreach ($rslt as $val){
  $data[] = $val; 
}
echo json_encode($data);

the output is [{"column name":"dbData1"},{"column name":"dbData2"}]
Instead of the column name can I replace it to a custom name?
expected output:
[{"rec":"dbData1"},{"rec":"dbData2"}]

A:

Something like this :
foreach ($rslt as $val){
    $data[] = array('rec'=>$val['column name']); 
}
echo json_encode($data);

