我的全部功能
function jsonData(){
//$data = $this->DataSet->query("SELECT * FROM data_sets;");
$data = $this->DataSet->find('all', array(
'fields' => array('created','systolisch', 'diastolisch', 'gewicht', 'puls'),
));
$columns = array();
$values = array();
$count = count($data);
for($i=0; $i < $count; $i++)
{
$keys[] = array_values($data[$i]);
$values [] = array_values(array_keys($data[$i]));
}
$array = array(
$keys,
$values,
);
return new CakeResponse(array('body' => json_encode($array), 'type' => 'json'));
}
情况如下:
for($i=0; $i < $count; $i++)
{
$keys[] = array_values($data[$i]);
$values [] = array_values(array_keys($data[$i]));
}
这返回:
[[[{"created":"2013-10-29 14:16:38","systolisch":"77","diastolisch":"83","gewicht":"77","puls":"77"}],[{"created":"2013-10-29 14:52:00","systolisch":"99","diastolisch":"88","gewicht":"80","puls":"100"}]],[["DataSet"],["DataSet"]]]
我需要的是 array_values(array(keys) lile diastolisch 和 systolisch 的结果的键。这些值也应该呈现为普通值而不是对。我怎么能做到这一点?